0

I am trying to convert a CWnd* pointer to a custom control pointer. The custom control just extends CEdit. Below is what I have. pWnd was passed in. it is a CWnd*.

calEdit* test = (calEdit*)pWnd->GetDlgItem(pWnd->GetDlgCtrlID());

When I try to debug and see what the value of test is, none of its members can be evaluated. The CWnd* is definitely not the problem.

To be sure that the CWnd* is pointing to the control I want, I did pWnd->GetDlgCtrlID(), and the ID matches the expected control.

Ryan Haining
  • 35,360
  • 15
  • 114
  • 174
Jameswr.11
  • 70
  • 6

2 Answers2

0

try to use CEdit *pEdit = dynamic_cast<CEdit*>(pWnd)

Sergi0
  • 1,084
  • 14
  • 28
0

try to use :

CEdit *pEdit = reinterpret_cast<CEdit*>(pWnd);
if (pEdit != nullptr)
  // Do something here
Penny
  • 606
  • 1
  • 7
  • 15