|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Dim AcadApp As AutoCAD.AcadApplication
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'Private AcadApp As Object
Private lHwnd As Long '保存ACAD应用程序的窗口句柄
Private lState As Long '保存ACAD的初始窗口状态
Private r As RECT '保存ACAD的初始窗口位置
Function AcadApi()
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set AcadApp = CreateObject("AutoCAD.Application.16")
End If
AcadApp.Visible = True
Dim objEntity As Object
Dim DwgName As String
DwgName = App.Path & "\容积换热器2008-1-23\08RH01-00.dwg"
Set objEntity = AcadApp.Documents.Open(DwgName)
lHwnd = GetParent(GetParent(AcadApp.ActiveDocument.hwnd))
If lHwnd = 0 Then Exit Function
lState = AcadApp.WindowState
AcadApp.WindowState = 1 '设置ACAD的窗口状态为默认,用于保存窗口位置。
GetWindowRect lHwnd, r
SetParent lHwnd, Form1.hwnd
Form1.ScaleMode = vbPixels '将VB窗体默认的缇单位改为以像素为单位。
'SetWindowPos lHwnd, 0, Form1.ScaleLeft, Form1.ScaleTop, Form1.ScaleWidth, Form1.ScaleHeight, 0
SetWindowPos lHwnd, 0, Form1.ScaleLeft, Form1.ScaleTop, Form1.ScaleWidth * 2.7, Form1.ScaleHeight * 2.8, 0
Exit Function
ErrTrap:
On Error GoTo 0
End Function
AcadApi.rar
(1.04 KB, 下载次数: 177)
|
|