MFC Edit control produces debug assert on first action
Windows 11, Visual Studio 17.13.3, C++, MFC, dialog app
Question: In the dialog constructor, add code for an Edit Control to clear it and get a popup dialog stating: Debug Assertion Failed!
Details
I solicited Bing.com and ChatGPT (right name?) for example code and followed it. Found a learn.microosft.com web page and followed it. They give the same advice. Evidently there is something I don’t recognize because both produced the same result.
Create an MFC project with C++, add a second dialog, and get that dialog to open, build, run, be sure that works. In the second dialog, drop an Edit control and add code in the constructor to clear it. At the bottom of the h file VS automatically added this.
class C_Show_Numbers : public CDialog
{
``DECLARE_DYNAMIC(C_Show_Numbers)
…
public:
``CEdit ec_show_numbers_3;
``afx_msg void OnEnChangeShowNumbers3();
};
In the dot cpp file I added this
C_Show_Numbers::C_Show_Numbers(CWnd* pParent /*=nullptr*/)
``: CDialog(IDD_SHOW_NUMBERS, pParent)
{`` ``ec_show_numbers_3.Clear();
``ec_show_numbers_3.SetWindowTextW(_T("third text"));`` ``}
The result is the dialog shown below.
So what did I miss in the instructions?