Results 1 to 8 of 8

Thread: [RESOLVED] Postmessage - x,y coordinates wrong (MakeDWord)

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489

    Resolved [RESOLVED] Postmessage - x,y coordinates wrong (MakeDWord)

    (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.

    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
    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 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
    ...Am I missing something here?

    Using winspector, I've been spying on the form. Here are the results:

    When manually cliking the form:
    Code:
    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
    when using Command2_Click
    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
    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).

    Odd.

    Any feedback VERY welcome.

    (Edit: I did try SendMessage instead, ending up with the same results)
    Last edited by Krass; May 30th, 2007 at 03:20 PM.
    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width