Solved

Disable, then enable the Retry Button in a MessageBox

Posted on 2008-10-06
3
635 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

624 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