Solved

OnOK in Modal Dialog Box

Posted on 1998-03-06
5
457 Views
Last Modified: 2008-02-01
I have a modal dialog box in which the user clicks the OK button to start some processing.  A progress bar on the dialog box indicates the status of the processing.  However, there may be instances where I want to dialog box to come up and immediately start processing once it is on the screen(without input from the user).  How can I send on OnOK message without the user doing anything?
Thanks
0
Comment
Question by:bralston
  • 3
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 total points
ID: 1183110
You can call the OnOK() member member function.  Say something like this:

MyDlg dlg;
dlg.AutoOK = TRUE;
dlg.DoModal();

Then in your dialog (probably sometime after the dialog is drawn) you can do:

if(AutoOK){
  OnOK();
}

I'm sure there are many other ways as well.  If so, someone will surely point them out...
0
 
LVL 32

Expert Comment

by:jhance
ID: 1183111
BTW, the AutoOK is a variable that you define in the Mydlg class.
0
 

Author Comment

by:bralston
ID: 1183112
jhance's suggestion is interesting, but doesn't quite do what I want.  The user would still have to interact with the dialog to get things to work.  I have come up with a different approach.  Instead of using
   dlg.DoModal()
I use the following
   dlg.Create(IDD_DIALOG1,NULL);
   dlg.ShowWindow(SW_SHOW);
   dlg.OnOK2();

OnOK2 is a public function which gives me access to the protected OnOK().

Thanks to everyone who responded.
0
 

Author Comment

by:bralston
ID: 1183113
jhance's suggestion is interesting, but doesn't quite do what I want.  The user would still have to interact with the dialog to get things to work.  I have come up with a different approach.  Instead of using
   dlg.DoModal()
I use the following
   dlg.Create(IDD_DIALOG1,NULL);
   dlg.ShowWindow(SW_SHOW);
   dlg.UpdateWindow();
   dlg.OnOK2();

OnOK2 is a public function which gives me access to the protected OnOK().

Thanks to everyone who responded.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1183114
Yes, that would do it.  Another thing I've done is set a timer in the dialog WM_INIT handler and then if the user doesn't do something in a certain period of time, press the OK or CANCEL for them so the application will continue.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

832 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