🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Need help (MFC)

Started by
2 comments, last by illuna 24 years, 6 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
Advertisement
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;
}
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