Home > Software engineering >  MFC neutron dialog class how to call the main dialog box class member variables
MFC neutron dialog class how to call the main dialog box class member variables

Time:11-25

MFC neutron dialog class how to call the main dialog box class member variables, such as child dialog box Number2 according to the Number1 in the main dialog box to determine, how to realize the function of similar "Number2=Number1", want to more specific explanation,

CodePudding user response:

Generally modify child dialog class constructors, need what parameters and then add what type of, construct child dialogs/pointer to the class object parameter passing in the past,

CodePudding user response:

Use of global variables

CodePudding user response:

Int I=((CParentDlg *) GetParent ()) - & gt; The Number1;


CodePudding user response:

Add a variable in the dialog box class, set this variable in the classwizard, connection, assignment,

CodePudding user response:

Add a variable in the dialog box class, before DoModal subsidiary to the parent window dialog box for the variable assignment,

CodePudding user response:

refer to the original poster JUST814 response:
MFC neutron dialog class how to call the main dialog box class member variables, such as child dialog box Number2 according to the Number1 in the main dialog box to determine, how to realize the function of similar "Number2=Number1", want to more specific explanation,

Dialog box to add a member, visit member type dialog box class pointer type, and make it points to the main dialog box, used to visit a pointer can access the main dialog box class members,
A dialog class header files:
# include "FatherDlg. H"
Private:
PDlg CFatherDlg *;

Child dialogs source files in OnInitDlg function:
PDlg=(CFatherDlg *) AfxGetmainDlg ();
Mumber2=pDlg - & gt; The Number1;

CodePudding user response:

AfxGetMainWnd phone, playing the function name incorrect. () your debugging.

CodePudding user response:

TheApp. M_pMainFrame - & gt; m_nXXX

CodePudding user response:

Define a main dialog box class object theApp, Number1 yes member variables, can be called directly, and then assigned to Number2
  • Related