API函数getWindowRect()的定义
Private Declare Auto Function GetWindowRect Lib "user32" (ByVal hwnd As IntPtr, ByVal lpRect As RECT) As Long
位置信息结构体
Public Structure RECTPublic left As Int32
Public top As Int32
Public right As Int32
Public bottom As Int32
End Structure
调用
GetWindowRect(Me.Handle, p1)
问题描述:
使用GetWindowRect函数来获取窗体的位置信息时,RECT中的left ,top ,right ,bottom 都是0
产生问题的原因:
API传递结构一般不用ByVal
解决方案:
ByVal lpRect As RECT改成ByRef lpRect As RECT