通过 GetWindowRect 可以得到一个窗口的位置和大小.
但能过getClientRect无法得到一个客户区的位置,只能得到大小 .
但SPY++得到了,他是如何做的呢?
http://upload.banzhu.net/User_UploadFiles/2010/7/19/201007192228332587.jpg

解决方案 »

  1.   

    dim psl as pointl
    clienttoscreen hwnd,pslmsgbox "clientpoints is:" & psl.x & psl.ydim rct as rect
    getclientrect hwnd,rct
    rct.left = psl.x
    rct.top =psl.ymsgbox "client rect is: " rct.left,rct.top,rct.width,rct.height
      

  2.   


    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
    Private Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type
    Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As Long) As LongPrivate Sub Command1_Click()
        Dim rcWin As RECT
        Dim rcClient As RECT
        
        
        GetWindowRect Me.hwnd, rcWin
        GetClientRect Me.hwnd, rcClient
        ClientToScreen Me.hwnd, rcClient.Left
        
        Debug.Print "客户区在屏幕上的位置:", rcClient.Left, rcClient.Top
        Debug.Print "客户区在窗口中的位置:", rcClient.Left - rcWin.Left, rcClient.Top - rcWin.Top
    End Sub