[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 476
  • Last Modified:

OnOK in Modal Dialog Box

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
bralston
Asked:
bralston
  • 3
  • 2
1 Solution
 
jhanceCommented:
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
 
jhanceCommented:
BTW, the AutoOK is a variable that you define in the Mydlg class.
0
 
bralstonAuthor Commented:
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
 
bralstonAuthor Commented:
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
 
jhanceCommented:
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now