用GetWindowRect()行吗?GetWindowRect VB声明 
Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long 
说明 
获得整个窗口的范围矩形,窗口的边框、标题栏、滚动条及菜单等都在这个矩形内 
返回值 
Long,非零表示成功,零表示失败。会设置GetLastError 
参数表 
参数 类型及说明 
hwnd Long,想获得范围矩形的那个窗口的句柄 
lpRect RECT,指向一个RECT结构的指针,接受窗口左上角和右下角的屏幕坐标,
        屏幕坐标中随同窗口装载的矩形 
注解 
如将它与通过GetDesktopWindow获得的句柄联合使用,
可获得对整个可视显示区域(桌面)进行说明的矩形

解决方案 »

  1.   

    Declare Function GetWindowRect Lib "user32" Alias "GetWindowRect" (ByVal hwnd As Long, lpRect As RECT) As Long
    Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
    End Type需要的时候这样:
    dim r as rect
    getwindowrect me.hwnd(也可以是其他句柄), r
    那么窗体
    x = r.left
    y = r.top
    width= r.right-r.left
    height=r.bottom-r.top
      

  2.   

    我也想说用GetWindowRect(),可是人家已经说了!
      

  3.   

    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongDim wr As RECT
    GetWindowRect mWnd, WR
    wr.Left
    wr.Top
    Height = wr.Bottom - wr.Top
    Width = wr.Right - wr.Left