SendMessage to a MessageBox to simulate OK button click
Question
Thursday, April 13, 2006 10:26 PM
Is there a way to send a message to a dialog box created using MessageBox method, to simulate OK button click (without user input)?
Rajesh
All replies (2)
Friday, April 14, 2006 1:03 AM âś…Answered
Hmm, the problem with doing this is what are the values for the OK button. This should be simulated by sending a WM_COMMAND message to the message box window. But the problem is knowing what value to send as the wParam.
The standard value for IDOK, which is the general identifier for OK buttons, is 1 so you could try using the following code.
SendMessage(hMsgBox, WM_COMMAND, 1, NULL);
The wParam value would be 1 because the notification code for button click event is 0. If the button ID isn't 1 then I'm sorry I don't know what it would be, but this method should work, you just have to find out the ID for the OK button.
Thursday, September 14, 2006 10:02 AM
I can't believe this !
The SendMessage func is probably the best way to do this.
So now what about the System.Windows.Forms assembly for WinCE 5.0 ?!
all GUI library I used permit to simulate (or post, or send, or whatever) any kind of event on a Control if this one implements the event you wish to append.
SendMessage is the way to do that with .NET Framework, so know what about the .NET compact framework ?!!!!