如题(屏幕外,原来的位置)

解决方案 »

  1.   

    获取这个窗体的位置用下面这个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
      

  2.   

    移动之前先记录位置坐标
    GetWindowRect()
    然后MoveWindow()移回来
      

  3.   

    这个窗体很复杂
    像mdi又不像  总之窗体上面含有好多个窗体 
    哎...
      

  4.   


    这个是获取多句柄 移动多窗体的代码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个点保存到数组  然后移回来就获取数组里面的值  并移动或者大家有什么好的方法???谢谢大家啊...
      

  5.   

    定义一个结构,或者用数组也可以,用GetWindowRect一次得到左、上、右、下的坐标值,减一下就可以求出宽和高,或者用SetWindowPos更方便。
      

  6.   

    Option ExplicitPrivate m_WinRectCollection As Collection'移出并保存坐标
    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
      

  7.   

    不管有多少个独立窗体,你移动前肯定都知道它们的句柄撒!不然MoveWindow怎么工作!那么~~~~~~~~~~~~~移动前,根据每个句柄保存那个窗体原来的位置不就行了!取窗体位置信息请看4楼.