Solved

Disable, then enable the Retry Button in a MessageBox

Posted on 2008-10-06
3
626 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

685 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