Home > Software engineering >  VC neutron form closed without implement destructors
VC neutron form closed without implement destructors

Time:09-19

In the dialog box Create a child through the Create dialog box, when closing the dialog box, the destructor of the child dialogs not implemented, you need to perform

CodePudding user response:

Add WM_DISTROY destructor

CodePudding user response:

reference 1st floor SWWLLX response:
add WM_DISTROY destructor


Where to add, I added DestoryWindow () function, not the trigger

CodePudding user response:

refer to the second floor goodluck365168 response:
Quote: refer to 1st floor SWWLLX response:

Add WM_DISTROY destructor


Where to add, I added DestoryWindow () function, no trigger
you use class wizard to add a class right by rights should not ah

CodePudding user response:

You with modal dialog CDialog DLG directly;
DLG. DoModal ();


Then in your CDialog class add WM_Distory destruction function class wizard to add


Add a breakpoint debugging

CodePudding user response:

Response WM_DISTROY message free your things, not DestoryWindow () function

CodePudding user response:

reference 5 floor schlafenhamster reply:
response WM_DISTROY message free your things, not DestoryWindow () function


Child window is new, want to let the parent window of a pointer to the child window, delete, and become null

CodePudding user response:

Child window is new to save the pointer,
Fiction
P - & gt; DestoryWindow ();
The delete P;
P=0;

CodePudding user response:

If the parent window so that create the child window in B

CodePudding user response:

If the parent window that create the child window in B
To define a pointer to the child window B
B * m_pB;//A.h
Then create a window B
M_pB=new B;//A.c pp
M_pB - & gt; The Create ();//A.c pp
M_pB - & gt; ShowWindow ()//A.c pp
When B window pop up, and then click B window close button above, this time, and in which how to implement the following class
The delete m_pB;////the biggest pp
M_pB=NULL;//the biggest pp

CodePudding user response:


1 B window close button above will send WM_DESTROY
The CWnd * pParent=GetParent ();

The delete pParent - & gt; M_pB;
PParent - & gt; M_pB=NULL;//the biggest pp

2 A window closed window B
M_pB - & gt; DestoryWindow ();
The delete m_pB;
M_pB=0;

CodePudding user response:

When closing the window, WM_DESTORY didn't trigger, just set out OnClose ()

CodePudding user response:

The parent dialog active call DestroyWindow, delete
Or child window override PostNcDestroy, inside the delete this

CodePudding user response:

Interpretation of structure function, of course, did not perform when out of scope, download window object is not necessarily also uninstall, such as

CaDialog aDlg;
The if (aDlg DoModal ()==IDOK)//DoModal returns, the window has been unloaded, but class object is
{
//you can get some parameters from class object, if the window after unloading, object and release, so you can't get dialog box after the execution of related parameters
}

CodePudding user response:

refer to 12 floor zgl7903 reply:
father take the initiative to invoke the DestroyWindow dialog, delete
Or child window override PostNcDestroy, inside the delete this


The key is how to tell the parent window when closing the window to do it,

CodePudding user response:

1 B window close button above will send WM_DESTROY
CWnd * GetParent ();//get the parent window

The delete pParent - & gt; M_pB;
PParent - & gt; M_pB=NULL;//the biggest pp

CodePudding user response:

reference 15 floor schlafenhamster response:
1 B window close button above will send WM_DESTROY
CWnd * GetParent ();//get the parent window

The delete pParent - & gt; M_pB;
PParent - & gt; M_pB=NULL;//the biggest pp


Can't do that, in the function delete pParent - & gt; M_pB dropped the object is destroyed, and then perform functions at the back of the statement (at least one return statement) bound to go wrong

CodePudding user response:

Is a WM_DESTROY message, not WM_DISTROY, and if it is the child dialog box to add the news, will in the main dialog to close call again later,

CodePudding user response:

Window object will not automatically destroyed after turn off, because often want to know the user closes the o 'clock OK or Cancel before

Feeling is Doc/View, you want the CView is automatically in the destruction of their own,

To notify the parent window can directly use the observer pattern, the main window and the parent window is a different View of the same Model, the View to do an event to be notified of other let each View to deal with this event (similar CDocument: : UpdateAllViews),

CodePudding user response:

refer to 12 floor zgl7903 reply:
father take the initiative to invoke the DestroyWindow dialog, delete
Or child window override PostNcDestroy, inside the delete this
PostNcDestroy this is said to be the standard window class
  • Related