Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable, then enable the Retry Button in a MessageBox

Posted on 2008-10-06
3
Medium Priority
?
648 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 2000 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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 learn how to clear a vector as well as how to detect empty vectors in C++.

972 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