Home > Software engineering >  The error C2065: 'GetDIgltem: undeclared identifier
The error C2065: 'GetDIgltem: undeclared identifier

Time:09-29

Dinglu \ dingluDlg CPP (139) : error C2065: 'GetDIgltem: undeclared identifier
Why is this excuse me

CodePudding user response:

GetDIgltem belongs to the CWnd class member functions, when using, should first obtain the CWnd object (CDialog inherited from CWnd),

For example:

 void test (CYourDlg * pDlg) 
{
CEdit * editbox=(CEdit *) pDlg - & gt; GetDlgItem (IDC_EDIT1);
//other code
}


When call test, need incoming dialog object pointer,

Also can be the following situation:

 void CYourDlg: : OnBnClickedCancel () 
{
CEdit * editbox=(CEdit *) GetDlgItem (IDC_EDIT1);

//this is CYourDlg class member functions, will be hidden into a this pointer,
//(CEdit *) GetDlgItem (IDC_EDIT1) is equivalent to (CEdit *) this - & gt; GetDlgItem (IDC_EDIT1)
}


if you have any help to you, please adopt the answer, thank you

CodePudding user response:

CEdit * editbox= (CEdit *) GetDlgItem (IDC_EDIT1);
Where did you call GetDlgItem () your dialog box class should be no problem if you check the ID is the controls in the RC file ID
  • Related