I've recently bought Programming Windows with MFC by Jeff Prosise, and I must say, it is a great book so far, but when I went to compile the sample source in MSVC++.NET, it would not compile. I've tried everything - I've created Win32 projects, MFC application projects, but nothing seems to work. I'm just wondering if there's a way to get the win32 projects to recognize MFC as an option when I'm configuring the project because when win32 is selected, the MFC option is blanked out.
I'm trying to compile the first "hello world" app, but with no avail. Here's the source in case anyone asks
Hello.h
Code:
class CMyApp : public CWinApp
{
public:
virtual BOOL InitInstance ();
};
class CMainWindow : public CFrameWnd
{
public:
CMainWindow ();
protected:
afx_msg void OnPaint ();
DECLARE_MESSAGE_MAP ()
};
Hello.cpp
Code:
#include <afxwin.h>
#include "Hello.h"
CMyApp myApp;
/////////////////////////////////////////////////////////////////////////
// CMyApp member functions
BOOL CMyApp::InitInstance ()
{
m_pMainWnd = new CMainWindow;
m_pMainWnd->ShowWindow (m_nCmdShow);
m_pMainWnd->UpdateWindow ();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions
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);
}
In the win32 project, whenever I compile, I get three errors, those being:
Code:
helloworld error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
Code:
helloworld error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)
Code:
helloworld fatal error LNK1120: 2 unresolved externals
I'm totally clueless about these errors. I admit, when it comes to windows programming, I'm a complete newbie. There's no two ways around it.
Any help is greatly appreciated, and more than welcome.