Solved

Program Crashes when re-opening a dialog box.

Posted on 1999-01-18
5
276 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

617 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