vb控制鼠标点击窗体内指定位置
vb控制鼠标点击窗体内指定位置,而不是在屏幕上,如点击窗体上(10,10)的位置
点击的坐标是按像素计算,还是其他的,会随显示器的大小而变吗,如何给控制不变
[解决办法]
Option ExplicitPrivate Const WM_LBUTTONDOWN As Long = &H201Private Const WM_LBUTTONUP As Long = &H202Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageW" ( _ ByVal hwnd As Long, _ ByVal wMsg As Long, _ ByVal wParam As Long, _ ByRef lParam As Any) As LongPrivate Sub Command1_Click() ReleaseCapture SetCapture Me.hwnd SendMessage Me.hwnd, WM_LBUTTONDOWN, 0&, ByVal &HA000A SendMessage Me.hwnd, WM_LBUTTONUP, 0&, ByVal &HA000AEnd SubPrivate Sub Form_Click() MsgBox "Form_Click"End Sub
[解决办法]
要补上这两个声明——刚才已经补过了,居然没更新,:(
&HA000A 的 HiWord 和 LowWord 就是 10 (&HA)
Private Declare Function ReleaseCapture Lib "user32.dll" () As LongPrivate Declare Function SetCapture Lib "user32.dll" (ByVal hwnd As Long) As Long