MFC: adding a control into a dialog window




void ChelloDlg::OnBnClickedEnable() {
CWnd *parentWnd = GetDlgItem(IDD_HELLO_DIALOG);
CStatic * newlabel = new CStatic();
newlabel->Create(_T("Hello World"), WS_CHILD | WS_VISIBLE,
CRect(10, 10, 100, 100), parentWnd);
}

I am using a button ID_ENABLE to trigger the adding of label into IDD_HELLO_DIALOG. The program would crash ("Debug Assertion Failed") when I hit the button.

What am I missing?


--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Xubuntu 8.04.1) Linux 2.6.26.5
^ ^ 20:40:02 up 3 days 5:30 3 users load average: 1.00 1.00 1.00
? ? (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa/
.


Loading