Click here to Skip to main content
15,925,133 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to compile win32 program in bcb 5.0 Pin
Johndotcom8-Feb-02 18:28
Johndotcom8-Feb-02 18:28 
GeneralCan't find the clrscr() program Pin
Fredrik N7-Feb-02 2:47
Fredrik N7-Feb-02 2:47 
GeneralRe: Can't find the clrscr() program Pin
Carlos Antollini7-Feb-02 3:06
Carlos Antollini7-Feb-02 3:06 
GeneralRe: Can't find the clrscr() program Pin
Atul Dharne7-Feb-02 3:26
Atul Dharne7-Feb-02 3:26 
GeneralA simple query on VC++ Pin
7-Feb-02 2:12
suss7-Feb-02 2:12 
GeneralRe: A simple query on VC++ Pin
Jon Hulatt7-Feb-02 2:41
Jon Hulatt7-Feb-02 2:41 
GeneralRe: A simple query on VC++ Pin
7-Feb-02 3:02
suss7-Feb-02 3:02 
GeneralRe: A simple query on VC++ Pin
Jon Hulatt7-Feb-02 3:27
Jon Hulatt7-Feb-02 3:27 
Don't try and delete the dialog from within the dialogs member function.

As a rule of thumb, and yes, there ARE many exceptions, but you should delete an object in the same block as you new'ed it in the first place. unless you specifically want the object to remain in existence once that code block is out of scope.

What you should do is this...

Your "theApp" object is the object that created the dialog, and called DoModal() on it. Since the dialog is modal, that thread blocks until the dialog closes.

Try something like this:

CMyWinApp::Whatever()
{
  CDialog1 *myDlg;
  CDialog2 *myDlg2;
  BOOL      bShowDlg1=TRUE;

  do {
    if (bShowDlg1) {
      myDlg = new CDialog1;
      myDlg.DoModal();
      delete myDlg;
      bShowDlg1=FALSE;
    } else {
      myDlg2 = new CDialog2;
      myDlg2.DoModal();
      delete myDlg2;
      bShowDlg1=TRUE;
    }
  } while (TRUE);
}

Then, in your dialogs:

CDialog1::OnClick()
{
  // i want to close this dialog:
  PostMessage(WM_CLOSE,0,0);
}


I expect you'll need to modify that to meet your exact needs. But you should take the pertinant points, that being to close the dialog with PostMessage() and have the parent object handle allocation and deallocation of the dialog.

Jon

Sorry to dissapoint you all with my lack of a witty or poignant signature.
GeneralRe: A simple query on VC++ Pin
7-Feb-02 4:21
suss7-Feb-02 4:21 
GeneralRe: A simple query on VC++ Pin
Jon Hulatt7-Feb-02 4:34
Jon Hulatt7-Feb-02 4:34 
GeneralRe: A simple query on VC++ Pin
pba_7-Feb-02 11:34
pba_7-Feb-02 11:34 
GeneralRe: A simple query on VC++ Pin
7-Feb-02 14:29
suss7-Feb-02 14:29 
GeneralRe: A simple query on VC++ Pin
pba_8-Feb-02 4:13
pba_8-Feb-02 4:13 
Generalarrays Pin
7-Feb-02 1:50
suss7-Feb-02 1:50 
GeneralRe: arrays Pin
Tim Smith7-Feb-02 2:31
Tim Smith7-Feb-02 2:31 
GeneralRe: arrays Pin
Jon Hulatt7-Feb-02 2:45
Jon Hulatt7-Feb-02 2:45 
GeneralRe: arrays Pin
7-Feb-02 4:27
suss7-Feb-02 4:27 
GeneralRe: arrays Pin
Jon Hulatt7-Feb-02 4:37
Jon Hulatt7-Feb-02 4:37 
GeneralRe: arrays Pin
Carlos Antollini7-Feb-02 3:08
Carlos Antollini7-Feb-02 3:08 
GeneralRe: arrays Pin
Christian Graus7-Feb-02 9:47
protectorChristian Graus7-Feb-02 9:47 
General.obj to .cpp file conversion.. Pin
Neha7-Feb-02 0:42
Neha7-Feb-02 0:42 
GeneralRe: .obj to .cpp file conversion.. Pin
Nish Nishant7-Feb-02 0:45
sitebuilderNish Nishant7-Feb-02 0:45 
GeneralRe: .obj to .cpp file conversion.. Pin
Neha7-Feb-02 0:51
Neha7-Feb-02 0:51 
GeneralRe: .obj to .cpp file conversion.. Pin
Atul Dharne7-Feb-02 3:37
Atul Dharne7-Feb-02 3:37 
GeneralWP_MINBUTTON Pin
Swinefeaster6-Feb-02 23:30
Swinefeaster6-Feb-02 23:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.