Solved

OnOK in Modal Dialog Box

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

758 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

19 Experts available now in Live!

Get 1:1 Help Now