Archived

This topic is now archived and is closed to further replies.

Need help (MFC)

This topic is 6586 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
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);

}

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Or you could just buy Visual C++ and it will be alot easier.

Share this post


Link to post
Share on other sites