Control the Application Window
 
 
 

The ability to control the Application window allows developers the flexibility to create effective and intelligent applications. There will be times when it is appropriate for your application to minimize the AutoCAD window, perhaps while your code is performing work in another application such as Excel. Additionally, you will often want to verify the state of the AutoCAD window before performing such tasks as prompting for input from the user.

Using methods and properties found on the Application object, you can change the position, size, and visibility of the Application window. You can also use the WindowState property to minimize, maximize, and check the current state of the Application window.

Position and size the Application window

This example uses the WindowTop, WindowLeft, Width, and Height properties to position the AutoCAD Application window in the upper-left corner of the screen and size it to 400 pixels wide by 400 pixels high.

Sub Ch3_PositionApplicationWindow()
	ThisDrawing.Application.WindowTop = 0
	ThisDrawing.Application.WindowLeft = 0
	ThisDrawing.Application.width = 400
	ThisDrawing.Application.height = 400
End Sub

Maximize the Application window

Sub Ch3_MaximizeApplicationWindow()
	ThisDrawing.Application.WindowState = acMax
End Sub

Minimize the Application window

Sub Ch3_MinimizeApplicationWindow()
	ThisDrawing.Application.WindowState = acMin
End Sub

Find the current state of the Application window

This example queries the state of the Application window and displays the state in a message box to the user.

Sub Ch3_CurrentWindowState()
	Dim CurrWindowState As Integer
	Dim msg As String
	CurrWindowState = ThisDrawing.Application.WindowState
	msg = Choose(CurrWindowState, "normal", _
				 "minimized", "maximized") 
	MsgBox "The application window is " + msg
End Sub

Make the Application window invisible

The following code uses the Visible property to make the AutoCAD application invisible to the end user.

Sub Ch3_HideWindowState()
	ThisDrawing.Application.Visible = False
End Sub