Share
 
 

About Positioning and Sizing the Document Window (ActiveX)

Use the Document object to modify the position and size of any document window.

The Document window can be minimized or maximized by using the WindowState property, and you can find the current state of the Document window by using the WindowState property.

Position a Document window

This example uses the Width and Height properties to set the active Document window to 400 pixels wide by 400 pixels high.

AutoLISP
(vl-load-com)
(defun c:Ch3_SizeDocumentWindow ()
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj))

    (vla-put-Width doc 400)
    (vla-put-Height doc 400)
)
VBA (AutoCAD Only)
Sub Ch3_SizeDocumentWindow()
  ThisDrawing.Width = 400
  ThisDrawing.Height = 400
End Sub

Maximize the active Document window

AutoLISP
(vl-load-com)
(defun c:Ch3_MaximizeDocumentWindow ()
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj))

    (vla-put-WindowState doc acMax)
)
VBA (AutoCAD Only)
Sub Ch3_MaximizeDocumentWindow()
  ThisDrawing.WindowState = acMax
End Sub

Minimize the active Document window

AutoLISP
(vl-load-com)
(defun c:Ch3_MinimizeDocumentWindow ()
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj))

    (vla-put-WindowState doc acMin)
)
VBA (AutoCAD Only)
Sub Ch3_MinimizeDocumentWindow()
  ThisDrawing.WindowState = acMin
End Sub

Find the current state of the active Document window

AutoLISP
(vl-load-com)
(defun c:Ch3_CurrentWindowState()
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj)
          CurrWindowState (vla-get-WindowState doc)
          msg "")

    (cond
      ((= CurrWindowState 1)(setq msg "normal"))
      ((= CurrWindowState 2)(setq msg "minimized"))
      ((= CurrWindowState 3)(setq msg "maximized"))
    )

    (alert (strcat "The document window is " msg))
)
VBA (AutoCAD Only)
Sub Ch3_CurrentWindowState()
  Dim CurrWindowState As Integer
  Dim msg As String
  CurrWindowState = ThisDrawing.WindowState
  msg = Choose(CurrWindowState, "normal", "minimized", "maximized") 
  MsgBox "The document window is " + msg
End Sub

Was this information helpful?