Solved

Disable, then enable the Retry Button in a MessageBox

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now