<DllImport("user32.dll")> _
Private Shared Function SetParent(ByVal child As IntPtr, ByVal newParent As IntPtr) As IntPtr
End Function
Shared button1 As New System.Windows.Forms.Button()
<CommandMethod("sab")> _
Public Shared Sub ShowMe()
If button1 Is Nothing Then
button1 = New System.Windows.Forms.Button()
End If
button1.Location = New System.Drawing.Point(31, 29)
button1.Name = "button1"
button1.Size = New System.Drawing.Size(87, 35)
button1.TabIndex = 0
button1.Text = "button1"
button1.UseVisualStyleBackColor = True
AddHandler button1.Click, AddressOf button1_Click
Dim doc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
SetParent(button1.Handle, doc.Window.Handle)
End Sub
Private Shared Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
button1.Dispose()
End Sub
Private Shared Function SetParent(ByVal child As IntPtr, ByVal newParent As IntPtr) As IntPtr
End Function
Shared button1 As New System.Windows.Forms.Button()
<CommandMethod("sab")> _
Public Shared Sub ShowMe()
If button1 Is Nothing Then
button1 = New System.Windows.Forms.Button()
End If
button1.Location = New System.Drawing.Point(31, 29)
button1.Name = "button1"
button1.Size = New System.Drawing.Size(87, 35)
button1.TabIndex = 0
button1.Text = "button1"
button1.UseVisualStyleBackColor = True
AddHandler button1.Click, AddressOf button1_Click
Dim doc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
SetParent(button1.Handle, doc.Window.Handle)
End Sub
Private Shared Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
button1.Dispose()
End Sub
Public Class Class1
<DllImport("user32.dll")> _
Shared Function SetParent(child As IntPtr, newParent As IntPtr) As IntPtr
End Function
Shared panSysMenu As UcSysMenu
<Autodesk.AutoCAD.Runtime.CommandMethod("MyMenu")> _
Public Sub loadSysMenu()
Dim DocCollection As DocumentCollection = Application.DocumentManager
'文档创建事件
AddHandler DocCollection.DocumentCreated, AddressOf DocCollection_DocumentCreated
For Each doc As Document In DocCollection
panSysMenu = New UcSysMenu()
panSysMenu.Location = New System.Drawing.Point(31, 29)
SetParent(panSysMenu.Handle, doc.Window.Handle)
Next
End Sub
Sub DocCollection_DocumentCreated(sender As Object, e As DocumentCollectionEventArgs)
panSysMenu = New UcSysMenu()
panSysMenu.Location = New System.Drawing.Point(31, 29)
SetParent(panSysMenu.Handle, Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle)
End Sub
End Class
<DllImport("user32.dll")> _
Shared Function SetParent(child As IntPtr, newParent As IntPtr) As IntPtr
End Function
Shared panSysMenu As UcSysMenu
<Autodesk.AutoCAD.Runtime.CommandMethod("MyMenu")> _
Public Sub loadSysMenu()
Dim DocCollection As DocumentCollection = Application.DocumentManager
'文档创建事件
AddHandler DocCollection.DocumentCreated, AddressOf DocCollection_DocumentCreated
For Each doc As Document In DocCollection
panSysMenu = New UcSysMenu()
panSysMenu.Location = New System.Drawing.Point(31, 29)
SetParent(panSysMenu.Handle, doc.Window.Handle)
Next
End Sub
Sub DocCollection_DocumentCreated(sender As Object, e As DocumentCollectionEventArgs)
panSysMenu = New UcSysMenu()
panSysMenu.Location = New System.Drawing.Point(31, 29)
SetParent(panSysMenu.Handle, Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Window.Handle)
End Sub
End Class
[本日志由 tiancao1001 于 2018-06-24 11:57 PM 编辑]
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |