Entry Point for MFC Application

I created a new emty project. Then we added the cpp and header hello world files, taken from Jeff Profiz's book "Windows Programming with MFC". Set Use of MFCtoUse MFC in a Shared DLL

An error was received. entry point must be defined How to solve this problem?

CPP:

#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);
}

N

class CMyApp : public CWinApp
{
public:
    virtual BOOL InitInstance ();
};

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

protected:
    afx_msg void OnPaint ();
    DECLARE_MESSAGE_MAP ()
};
+4
source share
1 answer

You need to tell the compiler what it uses WinMain(which is provided by MFC: http://msdn.microsoft.com/en-us/library/akdx0603.aspx ) instead of mainas an entry point.

Right-click the project, select Propertiesand go to LinkerSystemSubSystem. Change SubSystemto Windows.

+4
source

Source: https://habr.com/ru/post/1535339/


All Articles