Window MFC get control's caption

 

 

it is the function GetWindowText rather than GetDlgItemText.

 

void MyCustomButton::OnPaint()
{
 int nid;
 CString  caption1, caption2;

 nid = this->GetDlgCtrlID();

 this->GetDlgItemText(nid, caption1);
 this->GetWindowText(caption2);

 std::cout << "control id = " << nid << "     caption = " << (LPCTSTR)caption2 << std::endl;
 
  ....

}

 

你可能感兴趣的:(Window MFC get control's caption)