| ForRealzZzZ (6) | |
|
Why doesnt this code work I have been following examples from a book I have and some of the functions in it are undefined by my compiler. I am compiling from Microsoft Visual Studio Ultimate and it still wont pick this one up. I just want to learn MFCs but, its like im programming in another language with no rules. Heres the cpp #include <afxwin.h> #include "header.h" CMyApp myApp; BOOL CMyApp::InitInstance() { m_pMainWindow = new CMainWindow; //the compiler doesnt seem to like this m_pMainWnd->ShowWindow(m_nCmdShow); // or the parameter in here m_pMainWnd->UpdateWindow(); return TRUE; } BEGIN_MESSAGE_MAP(CMainWindow, CFrameWnd) ON_WM_PAINT() END_MESSAGE_MAP() CMainWindow::CMainWindow() { Create(NULL,_T("The hellow application")); } void CMainWindow::OnPaint(){ CPaintDC dc (this); CRect rect; GetClientRect (&rect); dc.DrawText (_T ("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } and heres the header file class CMyApp{ public: virtual BOOL InitInstance(); }; class CMainWindow : public CFrameWnd{ public: CMainWindow(); protected: afx_msg void OnPaint(); DECLARE_MESSAGE_MAP() }; | |
|
|
|
| kbw (5520) | |
| What happens? | |
|
|
|
| modoran (1245) | |
| Why don't you use standard MFC auto generated code generated by VS 2010 wizard ? That is guaranteed to always work. | |
|
|
|
| ForRealzZzZ (6) | |
|
@kbw It doesnt run I put comments inside to tell what the compiler took and what it didnt. @modoran I could do that just to analyze the flow of MFCs and im probably going to ditch the book I have and get petzolds book this was literally one of the first examples in the book. | |
|
Last edited on
|
|