Solved

OnInitDialog

Posted on 2001-06-07
6
344 Views
Last Modified: 2006-11-17
I have a while statement that I run in OnInitDialog.  What happens now is when the program is executed, it runs the entire loop first, and then displayes the dialog.  
I would like it to display the diaplog first, then run the loop. How do I do this?
0
Comment
Question by:setfocus
  • 3
  • 3
6 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 6164333
Is this an MFC application?
0
 

Author Comment

by:setfocus
ID: 6164334
Yes, it is.
0
 
LVL 30

Accepted Solution

by:
Axter earned 60 total points
ID: 6164386
When I need to do something like that, I add a bool member to the Dialog class.

Then in the constructor I set in false:
Example:
CTest1Dlg::CTest1Dlg(CWnd* pParent /*=NULL*/)
     : CDialog(CTest1Dlg::IDD, pParent)
{
     m_bMadeFirstPass=false;

Then I test this variable in the OnPaint function, and if it's false, I run the procedure.

Example:
void CTest1Dlg::OnPaint()
{
//..........do OnPaint suff first

     if (!m_bMadeFirstPass)
     {
          m_bMadeFirstPass=true;
          AfxMessageBox("Do your routine here");
     }
}
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:setfocus
ID: 6164719
Would you add a BOOl member through class Wizard?  I am a new to C so any help would be appriciated.
0
 
LVL 30

Expert Comment

by:Axter
ID: 6164770
Would you add a BOOl member through class Wizard?

You can add it directly to the class.
Example:

class CTest1Dlg : public CDialog
{
     bool m_bMadeFirstPass;
// Construction
public:
0
 

Author Comment

by:setfocus
ID: 6165357
It worked great, thanks.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

730 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