'location
'   获取控件，以像素为单位的左上角的位置。位置是相对于客户端的左上角在父窗口中的区域。
'   hWndControl: 窗体或控件的句柄 (例如  HWND_FORM1_COMMAND1)
'   Returns:     0 if error, non-zero if successful
'                nLeft returns the left position of the window
'                nTop returns the top position of the window
Function FF_Control_GetLoc( ByVal hWndControl as HWnd, _
                            ByRef nLeft as Long, _
                            ByRef nTop as long _
                            ) as Integer
    
    Dim rc as Rect
    
    '检查窗口句柄是否有效
    If IsWindow(hWndControl) Then  
       
       ' Get the dimensions of the window
         Function = GetWindowRect( hWndControl, @rc)
        
       ' Convert the coordinates to be relative to the parent
         MapWindowPoints HWND_DESKTOP, GetParent(hWndControl), Cast(LPPOINT, VarPtr(rc)), 2
         
       ' Return the Left and Top values back from the function
         nLeft  = rc.Left
         nTop   = rc.Top
         
    End If
       

End Function

