1

If I have an MFC dialog with a button control on it, is there a way to get construct the HWND or CWND for that control using the button's ID (e.g IDC_BUTTON_YES)?

Amre
  • 1,630
  • 8
  • 29
  • 41

1 Answers1

4

Yes, you can use the function GetDlgItem of the MFC dialog!

Here is an example for you:

CWnd*  myWnd = this->GetDlgItem(IDC_LIST1);

// as CListBox

CListBox* myListBox = (CListBox*)this->GetDlgItem(IDC_LIST1);
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Tihomir Tashev
  • 185
  • 2
  • 9