Help needed getting started with MFC

Help needed getting started with MFC

Post by Seymour Shli » Tue, 30 Apr 1996 04:00:00



I am trying to start from a basic program to learn Visual
C++ version 4 MFC programming. When I build this program
the linker returns the message.

LNK2001: unresolved external symbol _main
Hello1.exe: fatal error LNK1120

Can anybody help me get started?

The program was found in the Microsoft System Journal,
"Wake Up and Smell the MFC:..." by Jeff Prosise.

I have successful working through the book
teach yourself Visual C++ 4 in 21 days. However, my
applications do not seem to fall in the categories
of dialog based, single document, and multiple document.


Seymour Shlien
(613) 998-2551
Ottawa, Canada
--------------------------------------------------------------------------

/* Hello1.h */
class CMyApp : public CWinApp
{
public:
    BOOL InitInstance ();

Quote:};

class CMainWindow : public CFrameWnd
{
public:
    CMainWindow ();

protected:
    afx_msg void OnPaint ();
    DECLARE_MESSAGE_MAP ()

Quote:};

/* Hello1.cpp */
#include <afxwin.h>
#include "hello1.h"

CMyApp myApp;

/////////////////////////////////////////////////////////////////////////////
// CMyApp member functions

BOOL CMyApp::InitInstance ()
{
    m_pMainWnd = new CMainWindow ();
    m_pMainWnd->ShowWindow (m_nCmdShow);
    m_pMainWnd->UpdateWindow ();
    return TRUE;

Quote:}

/////////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
    ON_WM_PAINT ()
END_MESSAGE_MAP ()

CMainWindow::CMainWindow ()
{
    Create (NULL, "Hello1");

Quote:}

void CMainWindow::OnPaint ()
{
    CRect rect;
    CPaintDC dc (this);

    GetClientRect (rect);
    dc.DrawText ("Hello, MFC", -1, rect, DT_SINGLELINE | DT_CENTER |
        DT_VCENTER);

Quote:}

 
 
 

Help needed getting started with MFC

Post by Alf P. Steinbac » Tue, 30 Apr 1996 04:00:00



> I am trying to start from a basic program to learn Visual
> C++ version 4 MFC programming. When I build this program
> the linker returns the message.

> LNK2001: unresolved external symbol _main
> Hello1.exe: fatal error LNK1120

> Can anybody help me get started?

If you really want to do this (not using AppWizard and ClassWizard)
use project type "Application", not project type "Console app" or
whatever it was called.  Problem:  I haven't found any way to
retrofit ClassWizard onto such a project.  Doc's say just create
empty file for it, or just don't have a file, select ClassWizard
and whoops, it should scan everything and come up.  But is disabled!

- Alf