?
Solved

Show MessageBox after CDialog is visible

Posted on 2003-03-05
3
Medium Priority
?
852 Views
Last Modified: 2013-11-20
I want a CDialog dialog to launch the MessageBox based on data it gets in OnInitDialog(). But the MessageBox must only be displayed after the dialog is visble.

How do I do this?

thanks
Doubletreemutt
0
Comment
Question by:doubletreemutt
[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 Comments
 
LVL 9

Expert Comment

by:Priyesh
ID: 8076971
try a PostMessage from the InitDialog, before the return TRUE and write a handler for the message, show your message box in this.

like

ON_MESSAGE(WM_USER+101, OnUserMessage)
DECLARE_MESSAGE_MAP()

BOOL CMyDialog::OnInitDialog()
{
   CDialog::OnInitDialog() ;
   
   //acquire data?
 
   PostMessage(WM_USER+101, 0, 0) ;
   
   return TRUE ;
   
}

LRESULT CMyDialog::OnUserMessage(WPARAM wPar, LPARAM lPar)
{
  AfxMessageBox("Init done") ;
  return 0 ;
}

add this line to your header
afx_msg LRESULT OnUserMessage(WPARAM wPar, LPARAM lPar) ;


or, you could start a timer from OnInitDialog after you acquire data, then have the message shown from the timer routine, and kill the timer, you could use a boolean variable to indicate if OnInitDialog is completed

or u could map ON_SHOW_WINDOW()

there might be more ways..
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 400 total points
ID: 8077354
You can do this on after your first OnPaint Call


void CYourDlg::OnPaint()
{
     .............
   
     static bool bFirst = true;
     
     if ( bFirst )
     {
          bFirst = false;
          // Show your message box here
     }
     ................
     ................
     ................
}


Good Luck
0
 

Author Comment

by:doubletreemutt
ID: 8082027
Thanks roshmon that works perfectly.

Thanks also to Priyesh - I had tried your first and third solutions already - both displayed the MessageBox() before the dialog was visible. A timer would work but I was looking for something simpler like the OnPaint.

Doubletreemutt
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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