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.
可以使用 Document 对象修改任何“文档”窗口的位置和大小。使用 WindowState 属性可以将“文档”窗口最小化或最大化,还可以查看“文档”窗口的当前状态。
Size the active Document window
This example uses the Location and Size Height properties to set the placement and size of Document window to 400 pixels wide by 400 pixels high.
本例使用 Location 和 Size 属性将活动“文档”窗口设置为宽 400 像素、高 400 像素。
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Windows
<CommandMethod("SizeDocumentWindow")> _
Public Sub SizeDocumentWindow()
'' “文档”窗口的大小 Size the Document window
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
acDoc.Window.WindowState = Window.State.Normal
'' 设置“文档”窗口的位置 Set the position of the Document window
Dim ptDoc As Point = New Point(0, 0)
acDoc.Window.Location = ptDoc
'' 设置“文档”窗口的大小 Set the size of the Document window
Dim szDoc As Size = New Size(400, 400)
acDoc.Window.Size = szDoc
End Sub
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;
acDoc.Window.WindowState = Window.State.Normal;
// 设置“文档”窗口的位置 Set the position of the Document window
Point ptDoc = new Point(0, 0);
acDoc.Window.Location = ptDoc;
// 设置“文档”窗口的大小 Set the size of the Document window
Size szDoc = new Size(400, 400);
acDoc.Window.Size = szDoc;
}
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Windows
<CommandMethod("MinMaxDocumentWindow")> _
Public Sub MinMaxDocumentWindow()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
'' 最小化文档窗口 Minimize the Document window
acDoc.Window.WindowState = Window.State.Minimized
MsgBox("Minimized", MsgBoxStyle.SystemModal, "MinMax")
'' 最大化文档窗口 Maximize the Document window
acDoc.Window.WindowState = Window.State.Maximized
MsgBox("Maximized", MsgBoxStyle.SystemModal, "MinMax")
End Sub
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");
}
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Windows
<CommandMethod("CurrentDocWindowState")> _
Public Sub CurrentDocWindowState()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
System.Windows.Forms.MessageBox.Show("The document window is " & _
acDoc.Window.WindowState.ToString(), "Window State")
End Sub
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");
}