Solved

Program Crashes when re-opening a dialog box.

Posted on 1999-01-18
5
241 Views
Last Modified: 2013-11-20
With my dialog box based prog, I have a dialog box tied to a button in another dialog box.  In other words, when I click the button, a new dialog box comes up.  My problem is this:  When I try to re-open the same dialog box I just closed, I get an assert error that stems from wincore.cpp, line 628.  
ASSERT(pWnd->m_hWnd == NULL);   // only do once
Why can't I reopen the dialog box I just closed?
0
Comment
Question by:kirts
  • 2
  • 2
5 Comments
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1327894
How is the dialog box closed?  What function do you call?
0
 

Accepted Solution

by:
bheld earned 100 total points
ID: 1327895
It sounds like whatever method you are using to close is destroying the m_hWnd member.  If you are calling CDialog::Create() followed by CDialog::ShowWindow(SW_SHOW) to show the dialog, you will need to call CDialog::Create after the dialog box is closed before showing it again.

If this is not clear - please provide the calls you are making to show and close the dialog box.
0
 

Author Comment

by:kirts
ID: 1327896
Using ClassWizard in VC++ 6.0 I tied a function call to a button to open my class of dialog box MotorDialog.  Basically, when the button is clicked, this dialog box pops up.  This is my code to make this happen, which works.  You say that when I close the box, it is destroying the instance of m_hWnd.  I'm pretty sure I follow that.  Do I need to tie a function to the WM_CLOSE message
and put some code in there to keep from destroying m_hWnd??


Here's what I have so far to open the box:


void CBluejayFlexorDlg::OnMotorButtonClicked()
{
MotorDialog motor_dialog_box;
int nResponse = motor_dialog_box.Create(IDD_DIALOG1, NULL);      
}
0
 

Expert Comment

by:bheld
ID: 1327897
So it is failing the second time this function is called?

I think you want to define motor_dialog_box NOT as a local variable but as a member of some class.  Then call create the first time this function is called.  For subsequent times,
If so, I believe the second time u just call ShowWindow(SW_SHOW).

Give this a try and let me know
0
 

Author Comment

by:kirts
ID: 1327898
Thanks a lot for the info.  I got it going correctly now.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

760 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