Below I have attached a simple windows program I am using from a book that teaches MFC (Thus the program name MFCSWP)
The book shows this as one of the simplest MFC Windows programs a person can write and yet it comes up with the wildest error when I try to compile it.
MCFSWP error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" (?AfxEndThread@@YGXIH@Z)
The only thing I can imagine is wrong here is that the code was written for Visual C++ 6 and I'm working with Visual Studio .Net. VC++ .Net when asked to generate a base program pulls up references to stdafx.h where as the version in the book is looking for afxwin.h.
The book specified no project type so I initially selected MFC application but that threw in a bunch of extra overhead code the book had not specified so, unable to get the the project tool to stop that, I went with a Blank Win32 app which gave me no files to start with. I also suspect the book wasn't clear on the extra overhead needed for the MFC support.
Is afxwin.h no longer valid in C++ .Net for windows programming?
What might I have done wrong here?
Any help would be greatly appreciated!
P.S. I did check for an errata for the book. The book is "The Complete Reference. Visual C++ 6 by Chris Pappas and William H. Murray.
Thanks
Code:
// Header file for MFCswp.h (swp = Simple Windows Program)
class CMainWnd : public CFrameWnd
{
public:
CMainWnd();
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
};
class CmfcswpApp : public CWinApp
{
public:
BOOL InitInstance();
};
// Code for MSCswp.CPP
#include <afxwin.h>
#include "mfcswp.h"
CmfcswpApp theApp;
CMainWnd::CMainWnd()
{
Create(NULL,"A MFC Windows Application",WS_OVERLAPPEDWINDOW,rectDefault,NULL,NULL);
}
void CMainWnd::OnPaint()
{
CPaintDC dc(this);
dc.TextOut(200,200,"Using the MFC Library",21);
}
BEGIN_MESSAGE_MAP(CMainWnd,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
BOOL CmfcswpApp::InitInstance()
{
m_pMainWnd=new CMainWnd();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}