Position and Size the Document Window (.NET)

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.

Size the active Document window

This example uses the Location and Size properties to set the placement and size of Document window to 400 pixels wide by 400 pixels high.

C# Example

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Windows;
 
[CommandMethod("SizeDocumentWindow")]
public static void SizeDocumentWindow()
{
    //Size the Document window
    Document acDoc = Application.DocumentManager.MdiActiveDocument;

    // Works around what looks to be a refresh problem with the Application window
    acDoc.Window.WindowState = Window.State.Normal;
            
    // Set the position of the Document window
    System.Windows.Point ptDoc = new System.Windows.Point(0, 0);
    acDoc.Window.DeviceIndependentLocation = ptDoc;

    // Set the size of the Document window
    System.Windows.Size szDoc = new System.Windows.Size(400, 400);
    acDoc.Window.DeviceIndependentSize = szDoc;
}

Minimize and maximize the active Document window

C# Example

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Windows;
 
[CommandMethod("MinMaxDocumentWindow")]
public static void MinMaxDocumentWindow()
{
    Document acDoc = Application.DocumentManager.MdiActiveDocument;

    //Minimize the Document window
    acDoc.Window.WindowState = Window.State.Minimized;
    System.Windows.Forms.MessageBox.Show("Minimized" , "MinMax");

    //Maximize the Document window
    acDoc.Window.WindowState = Window.State.Maximized;
    System.Windows.Forms.MessageBox.Show("Maximized" , "MinMax");
}

Find the current state of the active Document window

C# Example

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Windows;
 
[CommandMethod("CurrentDocWindowState")]
public static void CurrentDocWindowState()
{
    Document acDoc = Application.DocumentManager.MdiActiveDocument;

    System.Windows.Forms.MessageBox.Show("The document window is " +
    acDoc.Window.WindowState.ToString(), "Window State");
}