Advertisement

Need help (MFC)

Started by January 05, 2000 03:52 PM
2 comments, last by illuna 24 years, 11 months ago
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;
}
Advertisement
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);

}
Or you could just buy Visual C++ and it will be alot easier.

This topic is closed to new replies.

Advertisement