I have the following unmanaged C++ code:
MessageBox( NULL, strMessage, "Cool Product", MB_RETRYCANCEL | MB_ICONEXCLAMATION);
I want to disable the RETRY button for 10 seconds (for example), then enable it.
How can I do this?
I have the following unmanaged C++ code:
MessageBox( NULL, strMessage, "Cool Product", MB_RETRYCANCEL | MB_ICONEXCLAMATION);
I want to disable the RETRY button for 10 seconds (for example), then enable it.
How can I do this?
With the standard MessageBox call, you can't. You'd need to implement your own MessageBox in order to do this.
I don't believe this is possible with the standard message box call.
You would probably be better off writing your own message box that includes this functionality.
(Or, you could write a separate thread that continually watches the screen waiting for that message box to appear, disable the retry button, wait 10 seconds and reenable it. Not fun. Seriously, do it the other way.)
Since Vista you can use taskdialog -- a more sophisticated dialog than a simple message box. More info and links here.
You cannot directly manipulate the MessageBox controls, but you can use a hack. Install a WH_
CBT hook just before displaying the dialog and handle the HCBT_
ACTIVATE event. This will give you the HWND of the message box, so that you can do whatever you want with it (subclass it, manage its buttons and set a timer).
You can find a Custom MessageBox tutorial with demo code in James Brown's site.
I agree with efotinis, it's not impossible, once you have the HWND you can do whatever you want with it. It is just a matter of "do you really need the hacks or are you better off with just creating your own message box dialog"?
Another not so nice way of finding the HWND (which would obviously give you access to eveything in the message box) would be to start a thread and ciclically poll for the message box handle by using EnumChildWindows. But I personally would prefer the WH_CBT hook also.