Solved

OnOK in Modal Dialog Box

Posted on 1998-03-06
5
458 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

  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 …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

827 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