I am new to vc++. I want to know which is proper and efficient way of handling controls by using member variable or resource id of controls.
m_Name.SetWindowTextW(_T("xyz"));
or
SetDlgItemText(IDC_EDIT2,_T("xyz"));
or
CWnd* cwd = GetDlgItem(IDC_EDIT2);
cwd->SetWindowTextW(_T("xyz"));
The efficient way is to create a control member variable. You can do this in the resource editor by right-click on the control and select Add Variable.
Every time you use GetDlgItem with the resource ID then it iterates through all child controls to find the one with the specified ID. This iteration is inefficient when done for every GetDlgItem call.