?
Solved

OnInitDialog

Posted on 2001-06-07
6
Medium Priority
?
350 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 240 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
Independent Software Vendors: 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses

762 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