Solved

OnOK in Modal Dialog Box

Posted on 1998-03-06
5
462 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
[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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

734 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