MFC dialog box cross-file invocation

Source: Internet
Author: User

In the non-Doc source file Call dialog box, first set up a dialog box, define classes, variables and header file source files and so on. Because when you start to create a dialog box, you are not setting up a separate dialog box.

In order to refer to the contents of his CPP directly in the dialog box and modify the header and source files of the dialog box:

(To be exact, do not know what the benefits of this, if there are ideas welcome message!) Thank you! )

//=========== header File C_latticetransfdlg.h#include"resource.h"#include"Mylattice.h"//= = The file to which the dialog box is referencedclassC_latticetransfdlg: Publiccdialogex{declare_dynamic (C_LATTICETRANSFDLG) Public: C_latticetransfdlg (Cmylattice* Thelatticepos, cwnd* pparent = NULL);//Standard constructor ===== here constructor add Mylattice class    Virtual~C_latticetransfdlg (); #ifdef Afx_design_time//= = If the non-modal dialog needs to remove the ifdef conditional compiler      enum{IDD =Idd_transformdlg}; #endif}...//============ source file c_latticetransfdlg.cpp====#include"stdafx.h"#include"liu_occ.h"#include"c_latticetransf.h"#include"afxdialogex.h"C_latticetransfdlg::c_latticetransfdlg (Cmylattice* Thelatticepos, cwnd* pparent/*=null*/)//= = = Constructor function: CDialogEx (Idd_transformdlg, pparent), M_tx (0), M_ty (0), M_tz (0), M_rx (0), M_ry (0), M_rz (0), Iscomplete (false) {Mylatticepos=Thelatticepos;} C_latticetransfdlg::~C_latticetransfdlg () {} ...

To invoke a dialog box in another file:

After the dialog header file is included,

  #include "c_latticetransf.h"   
void Cmylattice::test5 () {C_latticetransfdlg * Latticetransfdlg; Latticetransfdlg = new C_latticetransfdlg ( this ->domodal (); = = modal Dialog open mode
// latticetransfdlg- >create (C_latticetransfdlg::idd, NULL);//== if the Non-modal dialog box uses the following statement // latticetransfdlg->showwindow (sw_show); float tx = Latticetransfdlg->TX; float rx = Latticetransfdlg->RX;}

The default is as follows, which can be referenced in other CPP:

//= = = Header FileclassC_latticetransfdlg: Publiccdialogex{declare_dynamic (C_LATTICETRANSFDLG) Public: C_latticetransfdlg (CWnd* pparent = NULL);//Standard Constructors    Virtual~C_latticetransfdlg ();//dialog box Data#ifdef Afx_design_time//enum {IDD = idd_dialog4};    enum{IDD =Idd_transformdlg};#endif...}//= = = Source fileC_latticetransfdlg::c_latticetransfdlg (cwnd* pparent/*=null*/): CDialogEx (Idd_transformdlg, pparent), M_tx (0), M_ty (0), M_tz (0), M_rx (0), M_ry (0), M_rz (0), Iscomplete (false){    /*mylatticepos = Thelatticepos;*/}//= = Other source filesvoidCmylattice::test5 () {C_latticetransfdlg*Latticetransfdlg; Latticetransfdlg=NewC_latticetransfdlg ();//= = Do not need this pointerLatticetransfdlg->DoModal (); //latticetransfdlg->create (C_latticetransfdlg::idd, NULL); //Latticetransfdlg->showwindow (sw_show); //myaiscontext->updatecurrentviewer ();    floattx = Latticetransfdlg->Tx; floatRx = latticetransfdlg->Rx;}

MFC dialog box cross-file invocation

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.