[MFC] Parent-Child dialog box intermodulation member variable

Source: Internet
Author: User

Because you want to use the modeless dialog box to do the tool panel, you need the child box to call the parent box member variables and member functions.
Previously used to send a message scheme, the same time trial parent pointer method was not successfully implemented,
This time, the successful implementation of the two pointer scheme, as follows:
Scenario One: The parent box creates a child box and passes the pointer.
P_dlg_filter = new Cdlg_filter;
P_dlg_filter->create (Idd_dialog_midfilter,null);
P_dlg_filter->showwindow (Sw_show);
P_dlg_filter->m_pmain = (void *) this;
First, a *m_pmain public variable of life in a child box class that points to itself when the parent box creates a child box;
Cvmat2d.copyto ((CDISHDECTDLG *) m_pmain)->CVMAT2);
(CDISHDECTDLG *) m_pmain)->displaymat1 ();
The pointer is then used in the child box to manipulate the members in the parent box (member variable CVMAT2, member function DISPLAYMAT1, and so on).


Scenario Two: Create a pointer inheritance directly in a child box (. ) Parent box.
Cdishdectdlg *pfilter1 = (Cdishdectdlg *) getparent ();
Pfilter1->cvmat1d.copyto (CVMAT2D);
PFILTER1->DISPLAYMAT1 ();




Declare the parent box pointer to inherit the parent box directly, call its member variables and function functions.


PS: In the article:
Cdishdectdlg---Parent box class name
P_dlg_filter---the Child box class pointer variable in the parent box


PPS: The above methods for reference from the network, if the infringement of the copyright, only for Laughs


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.