Newbie - MFC code from a book in VC++.Net

This is a discussion on Newbie - MFC code from a book in VC++.Net within the Windows Programming forums, part of the Platform Specific Boards category; Below I have attached a simple windows program I am using from a book that teaches MFC (Thus the program ...

  1. #1
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22

    Newbie - MFC code from a book in VC++.Net

    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;
    }
    Last edited by Guardian; 04-27-2002 at 03:42 PM.
    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Go to Configuration Properties/General in the properties dialog, and change the 'Use of MFC' box. I haven't tried your code, but I'm pretty sure this'll fix it.

  3. #3
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22
    Sorensen,
    That fixed it perfectly!
    Had a heck of a time locating the property because theres a "General" section in the properties of just about everything in the project, but I did find it and it worked like a charm.

    Thanks a bunch!
    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IPC between MFC and .NET
    By khdani in forum Windows Programming
    Replies: 2
    Last Post: 02-26-2009, 05:39 PM
  2. API or MFC in Managed C++ (.NET)
    By gwarf420 in forum Windows Programming
    Replies: 6
    Last Post: 10-23-2008, 05:36 PM
  3. Windows, MFC, .NET, C++ ???
    By alpha in forum Windows Programming
    Replies: 8
    Last Post: 08-07-2006, 03:31 PM
  4. Newbie Source Code question. Hlp Plz?
    By BOOGIEMAN in forum Game Programming
    Replies: 4
    Last Post: 12-14-2001, 04:30 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 03:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21