Home > Software engineering >  MFC VC how to create your own has control of the CPP check status?
MFC VC how to create your own has control of the CPP check status?

Time:11-23

CchuangkoutiaozhengDlg * pMain=(CchuangkoutiaozhengDlg *) AfxGetApp () - & gt; M_pMainWnd;
If (((CButton *) pMain - & gt; GetDlgItem (1191)) - & gt; GetCheck ()==0)
{
. ;
}
Check control ID is 1191, in the child window in the TAB. The code is written in the create CPP, and then the code error directly.
What should I write?

CodePudding user response:

The child window in the dialog box under the TAB

CodePudding user response:

reference 1st floor schlafenhamster response:
dialog box under the TAB in the child window

No, I want to know how to write code should
If (((CButton *) pMain - & gt; GetDlgItem (1191)) - & gt; GetCheck ()==0)
This is an error

CodePudding user response:

If the dialog is
The CWnd * pMain=AfxGetMainWnd ();//take dialog
If (((CButton *) (pMain - & gt; GetDlgItem (IDC_CHECK1))) - & gt; GetCheck ()==0)
If the Tab
The CWnd * pMain=AfxGetMainWnd ();//take dialog
CTabCtrl * pTab=pMain - & gt; GetDlgItem (IDC_TAB1);//pick up the TAB
If (((CButton *) (pTab - & gt; GetDlgItem (IDC_CHECK1))) - & gt; GetCheck ()==0)

CodePudding user response:

The
reference 3 floor schlafenhamster response:
if the dialog is
The CWnd * pMain=AfxGetMainWnd ();//take dialog
If (((CButton *) (pMain - & gt; GetDlgItem (IDC_CHECK1))) - & gt; GetCheck ()==0)
If the Tab
The CWnd * pMain=AfxGetMainWnd ();//take dialog
CTabCtrl * pTab=pMain - & gt; GetDlgItem (IDC_TAB1);//pick up the TAB
If (((CButton *) (pTab - & gt; GetDlgItem (IDC_CHECK1))) - & gt; GetCheck ()==0)




In the TAB that appears in a new problem, could not initialize?

CodePudding user response:

CTabCtrl * pTab= (CTabCtrl *) pMain - & gt; GetDlgItem (IDC_TAB1);//pick up the TAB
The CWnd * into CTabCtrl *

CodePudding user response:

You can't when you create the class you want to read the dialog content passed?
To read changes can also grasp the operation on the main window of notification messages, reading state again to your object,

CodePudding user response:

reference 5 floor schlafenhamster reply:
CTabCtrl * pTab= (CTabCtrl *) pMain - & gt; GetDlgItem (IDC_TAB1);//pick up the TAB
The CWnd * into CTabCtrl *


An error now, but still and started the same.






I am in the main window created a TAB control, and then built a child window when the TAB on the first page, check1 is in the child window.

CodePudding user response:

refer to 6th floor Jiang Sheng response:
you can't when you create the class you want to read the dialog content passed?
To read changes can also grasp the operation on the main window of notification messages, reading state again to your objects,


Because control is more, I read control using a for loop control ID, so each control so much trouble writing. Everything is normal, the Dialog window in a pointer to the CPP don't know how to build.

CodePudding user response:

CTabCtrl * pTab so can't convert CButton *

The CWnd * into CTabCtrl * because you know what is it

CodePudding user response:

references 9 f schlafenhamster response:
pTab so can't convert CButton CTabCtrl * *

The CWnd * into CTabCtrl * because you know what it is


No see, how to write

CodePudding user response:

Getting the multilevel pointer is added in the Tab of the parent class or derived class a public function, then put these on the function, convenient call also simplifies the operation
In addition through AfxGetApp () - & gt; M_pMainWnd access class, need give AfxGetApp () - & gt; M_pMainWnd fu with normal pointer, you can use the APP wizard generates a dialog-based application, the MFC framework structure under study

CodePudding user response:

Can declare the control variables, but also more convenient across files or dialog operation,
  • Related