Solved

OnInitDialog

Posted on 2001-06-07
6
342 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

929 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

11 Experts available now in Live!

Get 1:1 Help Now