compiling problem with ms visual c++

C

cppaddict

Hi,

I am trying to compile the first example of Jeff Prosise's book "Programming
Windows with MFC Second Edition" using Visual C++ version 7.1. The example
is very simple and consists of only two files (included below). Following
the book's instructions, I select a Win32 Application with empty project
selected, and add the two files. The compiler lists 2 unresolved externals
as the problem. I think it has to do with the version, b/c the book assumes
you are using the Visual C++ 6 IDE. Does anyone know how to fix the
problem?

Thanks,
cpp

Here are the two files:

hello.h
----------------------
class CMyApp : public CWinApp {
public:
virtual BOOL InitInstance();
};

class CMainWindow : public CFrameWnd {
public:
CMainWindow();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
};

hello.cpp
--------------------------------
// hello.cpp : Defines the entry point for the console application.
//

#include <afxwin.h>
#include "stdafx.h"
#include "hello.h"

CMyApp myApp;

BOOL CMyApp::InitInstance() {
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow;
return TRUE;
}

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()

CMainWindow::CMainWindow() {
Create (NULL, _T ("The Hello Application"));
}

void CMainWindow::OnPaint() {
CPaintDC dc(this);
CRect rect;
GetClientRect(&rect);
dc.DrawText(_T("Hello, MFC"), -1, &rect, DT_SINGLELINE | DT_CENTER |
DT_VCENTER);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top