Solved

OnInitDialog

Posted on 2001-06-07
6
341 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
Comment Utility
Is this an MFC application?
0
 

Author Comment

by:setfocus
Comment Utility
Yes, it is.
0
 
LVL 30

Accepted Solution

by:
Axter earned 60 total points
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:setfocus
Comment Utility
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
Comment Utility
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
Comment Utility
It worked great, thanks.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 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…

743 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

17 Experts available now in Live!

Get 1:1 Help Now