将cad嵌入到vb中

Option Explicit 
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 lHwnd As Long 
Private Sub Form_Load()
    
    On Error GoTo ErrTrap
    Dim acadApp As Object
    Set acadApp = CreateObject("AutoCAD.Application")
    acadApp.Visible = True
    lHwnd = GetParent(GetParent(acadApp.Activedocument.hwnd))
    If lHwnd = 0 Then Exit Sub
    SetParent lHwnd, Form1.hwnd
    Exit Sub
    
ErrTrap:
    On Error GoTo 0
End Sub 
Private Sub Form_Unload(Cancel As Integer)
    If lHwnd = 0 Then Exit Sub
    SetParent lHwnd, 0
End Sub
上一篇:TP6框架中引用KindEditor编辑器


下一篇:MySQL45讲之生产环境下的性能问题