获取这个窗体的位置用下面这个API: Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long 其中lpRect声明如下: Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type
移动之前先记录位置坐标 GetWindowRect() 然后MoveWindow()移回来
这个窗体很复杂 像mdi又不像 总之窗体上面含有好多个窗体 哎...
这个是获取多句柄 移动多窗体的代码Tmp_Hwnd = FindWindow(ByVal 0&, ByVal 0&) Do While Tmp_Hwnd <> 0 Call GetWindowThreadProcessId(Tmp_Hwnd, Tmp_Pid) If Tmp_Pid = pid Then If IsWindowVisible(Tmp_Hwnd) <> 0 Then GetPidFindHwnd = Tmp_Hwnd MoveWindow GetPidFindHwnd, 10000, 10000, 10000, 10000, False End If End If Tmp_Hwnd = GetWindow(Tmp_Hwnd, GW_HWNDNEXT) Loop在这个代码中 如果是将窗体移回来 怎么写啊 因为这个窗体里面又有好多个子窗体 不是mdi窗体 怎么样将每次获得句柄的窗体的坐标4个点保存到数组 然后移回来就获取数组里面的值 并移动或者大家有什么好的方法???谢谢大家啊...
If m_WinRectCollection Is Nothing Then Set m_WinRectCollection = New Collection End If m_WinRectCollection.Add rc.Left & "," & rc.Top & "," & rc.Right & "," & rc.bottom, _ "K" & Hex(hWndTarget) MoveWindow hWndTarget, 10000, 10000, rc.Right, rc.Top, 1 End Sub'移入并恢复坐标 Sub MoveIn(ByVal hWndTarget As Long) Dim sKey As String Dim a() As String
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long 其中lpRect声明如下:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
GetWindowRect()
然后MoveWindow()移回来
像mdi又不像 总之窗体上面含有好多个窗体
哎...
这个是获取多句柄 移动多窗体的代码Tmp_Hwnd = FindWindow(ByVal 0&, ByVal 0&)
Do While Tmp_Hwnd <> 0
Call GetWindowThreadProcessId(Tmp_Hwnd, Tmp_Pid)
If Tmp_Pid = pid Then
If IsWindowVisible(Tmp_Hwnd) <> 0 Then
GetPidFindHwnd = Tmp_Hwnd
MoveWindow GetPidFindHwnd, 10000, 10000, 10000, 10000, False
End If
End If
Tmp_Hwnd = GetWindow(Tmp_Hwnd, GW_HWNDNEXT)
Loop在这个代码中 如果是将窗体移回来 怎么写啊
因为这个窗体里面又有好多个子窗体 不是mdi窗体
怎么样将每次获得句柄的窗体的坐标4个点保存到数组 然后移回来就获取数组里面的值 并移动或者大家有什么好的方法???谢谢大家啊...
Sub MoveOut(ByVal hWndTarget As Long)
Dim rc As RECT
GetWindowRect hWndTarget, rc
rc.Right = rc.Right - rc.Left 'width
rc.bottom = rc.bottom - rc.Top 'height
If m_WinRectCollection Is Nothing Then
Set m_WinRectCollection = New Collection
End If
m_WinRectCollection.Add rc.Left & "," & rc.Top & "," & rc.Right & "," & rc.bottom, _
"K" & Hex(hWndTarget)
MoveWindow hWndTarget, 10000, 10000, rc.Right, rc.Top, 1
End Sub'移入并恢复坐标
Sub MoveIn(ByVal hWndTarget As Long)
Dim sKey As String
Dim a() As String
sKey = "K" & Hex(hWndTarget)
a = Split(m_WinRectCollection(sKey), ",")
m_WinRectCollection.Remove sKey
MoveWindow hWndTarget, CLng(a(0)), CLng(a(1)), CLng(a(2)), CLng(a(3)), 1
End Sub