MFC creating non-modal child windows

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.