Need help (MFC)
Okay I know my question sounds completly stupid but damn it I just can't create a stupid CButton!! *sorry guys*
void CMainWnd::init() {
/* Create the main window */
Create(NULL, "MainWindow", WS_OVERLAPPEDWINDOW, CRect(0,0,300,300), NULL, NULL);
/* What's wrong with those 2 lines?? */
/* It compiles, doesn't make any errors, returns TRUE (function worked) but it doesn't display anything in the main window!! I also tried to to do a "ShowWindow()" on "test" but it do nothing either. Help!!*/
CButton test;
test.Create("Test button", WS_CHILD/WS_VISIBLE, CRect(10,10,50,20), this, 1);
}
Thanks
Illuna*
Edited by - illuna on 1/5/00 3:55:55 PM
Edited by - illuna on 1/5/00 3:56:20 PM
To display your window you need to find the
BOOL CTheApp::InitInstance(); function and edit it to look like this:
BOOL CTheApp::InitInstance()
{
m_pMainWnd = new CMainWnd();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
BOOL CTheApp::InitInstance(); function and edit it to look like this:
BOOL CTheApp::InitInstance()
{
m_pMainWnd = new CMainWnd();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
Also, you need to put your call to Create in the function CMainWnd() (the constructor), not Init(); like this:
void CMainWnd::CMainWnd() {
/* Create the main window */
Create(NULL, "MainWindow", WS_OVERLAPPEDWINDOW, CRect(0,0,300,300), NULL,
NULL);
/* What''s wrong with those 2 lines?? */
/* It compiles, doesn''t make any errors, returns TRUE (function worked) but it doesn''t
display anything in the main window!! I also tried to to do a "ShowWindow()" on "test"
but it do nothing either. Help!!*/
CButton test;
test.Create("Test button", WS_CHILD/WS_VISIBLE, CRect(10,10,50,20), this, 1);
}
void CMainWnd::CMainWnd() {
/* Create the main window */
Create(NULL, "MainWindow", WS_OVERLAPPEDWINDOW, CRect(0,0,300,300), NULL,
NULL);
/* What''s wrong with those 2 lines?? */
/* It compiles, doesn''t make any errors, returns TRUE (function worked) but it doesn''t
display anything in the main window!! I also tried to to do a "ShowWindow()" on "test"
but it do nothing either. Help!!*/
CButton test;
test.Create("Test button", WS_CHILD/WS_VISIBLE, CRect(10,10,50,20), this, 1);
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement