PDA

Click to See Complete Forum and Search --> : Problem With PostMessage/Clicking


Falcondl
Jan 2nd, 2001, 02:56 AM
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...

Jan 2nd, 2001, 10:00 AM
Works for me.

Add the following to a Form with 2 CommandButtons.

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

Falcondl
Jan 2nd, 2001, 03:01 PM
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.