I created a control variable for CEdit:
class CGateDlg : public CDialog { ... public:
And this is how I map my variable to the control:
void CGateDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_EDIT_A, m_edit_a); }
Here's how it works: the user enters text in the edit box. Then he presses the "Reset" button, which clears the editing window. This is part of the code responsible for clearing the edit window after clicking the Reset button:
void CGateDlg::OnBnClickedReset() {
The application starts without errors. I type in the EditBox and click on the "Reset" button. Then I get an error message that leads me to winocc.cpp, line 245 (ENSURE (this)):
void CWnd::SetWindowText(LPCTSTR lpszString) { ENSURE(this); ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL)); if (m_pCtrlSite == NULL) ::SetWindowText(m_hWnd, lpszString); else m_pCtrlSite->SetWindowText(lpszString); }
I think the problem is with hWnd:
this 0x0030fa54 {CEdit hWnd=0x00000000} CWnd * const
but how to fix it?
Everything works fine when I access my control value with this:
CEdit *m_edit_a; m_edit_a = reinterpret_cast<CEdit *>(GetDlgItem(IDC_EDIT_A)); m_edit_a->SetWindowTextW(L"");
What am I doing wrong?
source share