Solved

Disable, then enable the Retry Button in a MessageBox

Posted on 2008-10-06
3
625 Views
Last Modified: 2013-11-25
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?
0
Comment
Question by:rcoast
3 Comments
 

Expert Comment

by:specialagent8305
ID: 22654236
You cannot (or I am not aware) do this with a message box. You have to create a custon dialog, or easiest yet... Creat a form that represents a dialog-box, with the border style as dialog... The rest should be easy... If the form should return a result, a custom dialog is best... Otherwise, a standard form should do the trick... (This is how I do it, anyway!)
0
 

Author Comment

by:rcoast
ID: 22654255
Can you point me in the direction of a tutorial on how to do this? I want to avoid MFC and ATL and use only standard Win32 API calls.
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 500 total points
ID: 22658095
>>>> You cannot (or I am not aware) do this with a message box.
You could start a thread which for example calls FindWindow(NULL, "Cool Product") to retrieve the handle of the message box (dialog) window. Then, call GetWindow to iterate the child windows of the message box. One of them - most probably - is the Retry button (you may call GetWindowText to retrieve the button's text for identification). You can retrieve its dialog item ID by calling GetDlgCtrlID. If you once know the ID you could get the button's window handle by calling GetDlgItem(hwndMBox, idRetryButton);


Then

   EnableWindow(hwndRetry, FALSE);
   Sleep(10000);
   if (IsWindow(hwndRetry))
       EnableWindow(hwndRetry, TRUE);

should do what you intend.  
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question