MFC: adding a control into a dialog window
- From: "Man-wai Chang ToDie (33.6k)" <toylet.toylet@xxxxxxxxx>
- Date: Fri, 12 Sep 2008 20:41:53 +0800
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/
.
- Follow-Ups:
- Re: MFC: adding a control into a dialog window
- From: David Wilkinson
- Re: MFC: adding a control into a dialog window
- Prev by Date: Problem dynamically creating CStatic Label: (FAIL afxwin1.inl line
- Next by Date: Re: My program not visible using Remote Desktop.
- Previous by thread: Problem dynamically creating CStatic Label: (FAIL afxwin1.inl line
- Next by thread: Re: MFC: adding a control into a dialog window
- Index(es):
Loading