怎样获取CAD绘图区域左上角的屏幕坐标(代码篇)
_
Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef lpRect As RECT) As Boolean
End Function
_
Public Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
_
Public Shared Function GetTopWindow(ByVal hWnd As IntPtr) As IntPtr
End Function
_
Public Shared Function GetWindow(ByVal hWnd As IntPtr, ByVal uCmd As UInt32) As IntPtr
End Function Public Shared Function GetChildWindows(ByVal ParentWindowsHandle As IntPtr) As List(Of IntPtr)
Dim rtn As New List(Of IntPtr)
Try
Dim Handle As IntPtr = GetTopWindow(ParentWindowsHandle)
While Handle0
rtn.Add(Handle)
Handle = GetWindow(Handle, 2)
End While
Catch ex As Exception
End Try
Return rtn
End Function
_
Sub T1()
Dim doc As Document = Autodesk..ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim HandleList As List(Of IntPtr) = GetChildWindows(doc.Window.Handle)
Dim Rect As New RECT() With {.Bottom = 0, .Left = 0, .Right = 0, .Top = 0}
GetWindowRect(HandleList(1), Rect) 'HandleList里有3个句柄,第2个为绘图区域的句柄
doc.Editor.WriteMessage(String.Format("绘图区域左上角屏幕坐标为:x={0},y={1},宽度为:{2},高度为:{3}", Rect.Left, Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top))
End Sub 同步学习一下………………谢谢
页:
[1]