Thread: MFC with .NET

  1. #1
    Registered User dead_cell's Avatar
    Join Date
    Jun 2002
    Posts
    44

    Unhappy MFC with .NET

    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.
    Last edited by dead_cell; 08-19-2002 at 04:07 PM.
    Linux is great - It does infinite loops in five seconds!

    ~Linus Torvalds

  2. #2
    Registered User dead_cell's Avatar
    Join Date
    Jun 2002
    Posts
    44
    Never mind, I figured it out myself...
    Linux is great - It does infinite loops in five seconds!

    ~Linus Torvalds

  3. #3
    Banned Troll_King's Avatar
    Join Date
    Oct 2001
    Posts
    1,784
    Choose New Solution - Visual C++ Projects - MFC application.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Windows, MFC, .NET, C++ ???
    By alpha in forum Windows Programming
    Replies: 8
    Last Post: 08-07-2006, 02:31 PM
  2. Which one :MFC, Win32, Windows Forms (.Net)?
    By Robert_Sitter in forum Windows Programming
    Replies: 6
    Last Post: 11-17-2005, 06:15 AM
  3. MFC, WTL or .NET?
    By microchip in forum C++ Programming
    Replies: 7
    Last Post: 11-07-2005, 03:14 PM
  4. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM