Solved

Program Crashes when re-opening a dialog box.

Posted on 1999-01-18
5
248 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
[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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 117
How to match SAS datasets by multiple key variables and then rename and create new variables? 2 117
NotAlone Challenge 20 93
unix example issues 18 114
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Suggested Courses

752 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