Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MFC Novice needs guidance...

Status
Not open for further replies.

slagathor

Technical User
Joined
Sep 13, 2003
Messages
5
Location
US
I am borderline competent in core C++, and am trying to familiarize myself with MFC. To do this, I am trying to write an MFC app without using App Wizard. App Wizard is great, but when you are trying to learn what is really going on, it is worthless. It creates about 5 or 6 different classes and deep header files that lose me. I want to figure how things are really working.... ie start simple...

Problem is with VC7, when I write a basic, bare bones MFC program, it won't link. Here is the code:


This is all in main.cpp---

#include <afxwin.h>

class CMainWin : public CFrameWnd
{
public:
CMainWin();
DECLARE_MESSAGE_MAP()
};

CMainWin::CMainWin()
{
Create(NULL, &quot;Minimum MFC App&quot;);
}

class CApp : public CWinApp
{
public:
BOOL InitInstance();
};

BOOL CApp::InitInstance()
{
m_pMainWnd = new CMainWin;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();

return TRUE;
}

BEGIN_MESSAGE_MAP(CMainWin, CFrameWnd)
END_MESSAGE_MAP()

CApp App;


Here are the link errors:

nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __endthreadex referenced in function &quot;void __stdcall AfxEndThread(unsigned int,int)&quot; (?AfxEndThread@@YGXIH@Z)

nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __beginthreadex referenced in function &quot;public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)&quot; (?CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)

Debug/MFC No Wizard.exe : fatal error LNK1120: 2 unresolved externals


Is this beacuse I started out with a blank project and it does not know that I want to use MFC? I cant find any way to trick the wizards into letting me build a simple project like this.

I even build a project using App Wizard, then copied the stdafx.h file and copied over to my simple project and referenced it in my main.cpp header....no dice....same error.

Any suggestions.
 
I have only done console MFC programs so far, but believe this error my be relavent to one I am familiar with. Simply go to project properties and in General locate &quot;Use of MFC&quot;. Set it to &quot;Use MFC in a shared dll&quot; This will compile, but the problem is it won't work on someone else's computer. All you should have to do is select use MFC in a static library -- but this option currently doesn't link properly for me and I am still in the dark.

-Bones
 
My suggestion is that you get a book targting beginner MFC Windows developers. They will cover most of the topics you are interested in.

If the book does not go into enough detail, you will be well armed with the basics to do online research to find more in depth information. Both MSDN Online and MSND Magazine Archives are a great source for MFC internals information.

A good MFC book will probably have the type of application (bare bones MFC Window) as one of it's projects.

-pete
 
If you have no clue what book to get I would recommend getting Introduction to MFC Programming with Visual C++ by Richard M. Jones -- so far it is proving itself very helpful to me.

-Bones
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top