In the first window, create a second window with the following code:
#include "second.h"//second window header file void Ctestdlg::onbnclickedbutton6 () {Seconddig *pdig = new Seconddig; Pdig->create (Idd_second); Pdig->showwindow (SW_SHOWNORMAL); }
If you want to destroy a child window in the second window. The following two virtual functions are handled first, as follows:
void Seconddig::P Ostncdestroy () {//TODO: Add private code here and/or call base class CDialogEx::P Ostncdestroy (); Delete this; } void Seconddig::oncancel () {//TODO: Add the dedicated code here and/or call the base class DestroyWindow (); Cdialogex::oncancel (); }
Rewrite the above two virtual functions. If the button is complete, call OnCancel () in the button click Message or use the following code
Exit the entire program:
PostQuitMessage (0);//or//afxgetmainwnd ()->sendmessage (wm_close,0,0);
MFC creating non-modal child windows