Results 1 to 3 of 3

Thread: Problem With PostMessage/Clicking

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    39

    Angry

    I made two dummy test applications to make sure i was right...

    i used
    Call PostMessage(tmphwnd, WM_LBUTTONDOWN, MK_LBUTTON, 0)
    Call PostMessage(tmphwnd, WM_LBUTTONUP, MK_LBUTTON, 0)

    This works on the button i want to click, but ONLY when it doesn't have the focus (that dotted box around the text in the button). When it doesn't have the focus, a message box pops up, it does what it has to do, etc...but nothing happens when it does have the focus.

    Is there anything else i can use? has anyone else had this problem??

    thanks for the help...

    on a side note, why does rval = Postmessage(...etc) not work at all? whats the diff between
    PostMessage(...)
    and
    PostMessage hwnd, wm...etc...

    i thought they work exactly the same, but one doesn't work and one does...

  2. #2
    Guest
    Works for me.

    Add the following to a Form with 2 CommandButtons.
    Code:
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Const WM_LBUTTONDOWN = &H201
    Private Const WM_LBUTTONUP = &H202
    Private Const MK_LBUTTON = &H1
    
    Private Sub Command1_Click()
        MsgBox "You pressed Command1"
    End Sub
    
    Private Sub Command2_Click()
        retv = PostMessage(Command1.hwnd, WM_LBUTTONDOWN, MK_LBUTTON, 0)
        retv = PostMessage(Command1.hwnd, WM_LBUTTONUP, MK_LBUTTON, 0)
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    39
    Yes, that works fine...

    But i have two SEPERATE programs...
    one of them has one (command1) button and mbsgox "clicked!" in the click event...

    the other finds the handle of that command button and does the PostMessage call...

    as long as command1 doesn't have the focus when i try to have the other program 'click' it, it works. when it does have the focus, it doesn't work.

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