CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ObjectARX 开发指南

放置文档窗口并调整其大小 (.NET)

2023-1-1 16:20| 发布者: admin| 查看: 1200| 评论: 0|来自: AutoCAD

使用 object 修改任何文档窗口的位置和大小。可以使用属性最小化或最大化“文档”窗口,并且可以使用属性查找“文档”窗口的当前状态。DocumentWindowStateWindowState

调整活动“文档”窗口的大小

本示例使用“位置和属性”将“文档”窗口的位置和大小设置为 400 像素宽 x 400 像素高。Size

VB.NET

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 System.Windows.Point = New System.Windows.Point(0, 0)
    acDoc.Window.DeviceIndependentLocation = ptdoc

    '' Set the size of the Document window
    Dim szDoc As System.Windows.Size = New System.Windows.Size(400, 400)
    acDoc.Window.DeviceIndependentSize = szDoc
End Sub

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

VBA/ActiveX 代码参考

Sub SizeDocumentWindow()
    ThisDrawing.Width = 400
    ThisDrawing.Height = 400
End Sub

最小化和最大化活动文档窗口

VB.NET

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

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

VBA/ActiveX Code Reference

Sub MinMaxDocumentWindow()
    '' Minimize the Document window
    ThisDrawing.WindowState = acMin
    MsgBox "Minimized"
 
    '' Minimize the Document window
    ThisDrawing.WindowState = acMax
    MsgBox "Maximized"
End Sub

Find the current state of the active Document window

VB.NET

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

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

VBA/ActiveX 代码参考

Sub CurrentDocWindowState()
    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

路过

雷人

握手

鲜花

鸡蛋

最新评论

AutoCAD Civil 3D.NET二次开发

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-7 04:59

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部