cangcang朋友提供的将Autocad界面嵌入到VB窗口的代码
[CODE][/CODE]
Public Sub AutoCAD_Appliaction(pic As VB.PictureBox, AcadApp As AcadApplication, AcadDoc As AcadDocument) '调用AUTOCAD在VB图形窗口中
On Error Resume Next
Dim i As Integer
Set AcadApp = GetObject(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set AcadApp = CreateObject("AutoCAD.Application.16")
If Err Then
pic.Visible = False
MsgBox Err.Description
pic.Visible = True
Exit Sub
End If
Else
If AcadApp.Documents.Count > 1 Then
For i = AcadApp.Documents.Count To 1 Step -1
Set AcadDoc = AcadApp.Documents.Item(i - 1)
AcadDoc.Save
AcadDoc.Close
Next
End If
End If
Set AcadDoc = Nothing
Dim z As AcadMenuGroup
Dim j As AcadToolbar
For Each z In AcadApp.MenuGroups
For Each j In z.Toolbars
j.Delete
Next j
Next z
lHwnd = GetParent(GetParent(AcadApp.ActiveDocument.hwnd))
If lHwnd = 0 Then Exit Sub
SetParent lHwnd, pic.hwnd
SetWindowText lHwnd, "图形显示"
AcadApp.Visible = True
AcadApp.WindowState = acMax