(I had another thread dealing with my current problem - but my needs evolved so I think a new thread couldn't hurt - also helping me to reach more people)
Here's the code I use. PostMessage sends a click on my vb-form, and the Form_MouseDown reacts to it by msgbox'ing the coordinates.
When clicking Command2, the Form_MouseDown even *IS* fired, but always white those coords: x: -45600 y:285. No matter what value I send to MakeDWord, I end up with -45600,285.Code:Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, y As Single) MsgBox "x: " & X & " y: " & y End Sub Private Sub Command2_Click() Call PostMessage(Me.hwnd, WM_LBUTTONDOWN, 0&, MakeDWord(200, 200)) Call PostMessage(Me.hwnd, WM_LBUTTONUP, 0&, 0&) End Sub
...Am I missing something here?Code:Private Declare Function PostMessage& Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) Function MakeDWord(LoWord As Integer, HiWord As Integer) As Long MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&) End Function
Using winspector, I've been spying on the form. Here are the results:
When manually cliking the form:
when using Command2_ClickCode:WM_LBUTTONDOWN - Mouse coordinates: 325,184 WM_LBUTTONDOWN - Mouse coordinates: 325,184, Button pressed: MK_LBUTTON WM_LBUTTONUP - wParam: 0x00000001, lParam: 0x00b80145 WM_LBUTTONUP - wParam: 0x00000000, lParam: 0x00b80145
Even tho the 2nd solution shows -3200, 19, the msgbox still shows "-45600,285" - OH, actually I just noticed the msgbox now shows "-48000,285" (I think those numbers changed because I've closed and rerunned my VB app).Code:WM_LBUTTONDOWN - Mouse coordinates: -3200, 19 WM_LBUTTONDOWN - Mouse coordinates: -3200, 19 WM_LBUTTONUP - wParam: 0x00000000, lParam: 0x0013f380 WM_LBUTTONUP - wParam: 0x00000000, lParam: 0x0013f380
Odd.
Any feedback VERY welcome.
(Edit: I did try SendMessage instead, ending up with the same results)




Reply With Quote