ドキュメント ウィンドウの位置とサイズを変更する(.NET)

Document オブジェクトを使用して、あらゆるドキュメント ウィンドウの位置およびサイズを変更できます。ドキュメント ウィンドウは、WindowState プロパティを使用して最小化および最大化することができます。また WindowState プロパティを使用してドキュメント ウィンドウの現在の状態を確認できます。

アクティブなドキュメント ウィンドウのサイズを変更する

この例では、 [場所] プロパティと Size プロパティを使用して、ドキュメント ウィンドウの配置とサイズを幅 400 ピクセル×高さ 400 ピクセルに設定します。

C# の例

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;
}

アクティブなドキュメント ウィンドウを最小化および最大化する

C# の例

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");
}

アクティブなドキュメント ウィンドウの現在の状態を確認する

C# の例

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");
}