Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Program Crashes when re-opening a dialog box.

Posted on 1999-01-18
5
Medium Priority
?
369 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 400 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

971 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