program
mfc.h
class CMyApp : public CWinApp
{
public :
virtual BOOL INITINSTANCE();
};
class CMainWindow : public CFrameWnd
{
public : CMainWindow();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
};
mfc.cpp
#include<afxwin.h>
#include"mfc.h"
CMyApp myapp;
////////////////////////////////////////////////////////////////////////////////////////////////
// CMyapp member function
BOOL CMyApp :: INITINSTANCE()
{
m_pMainWnd=new CMainWindow();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return true;
}
/////////////////////////////////////////////////////////////////////////////////
////CWindow message map and member function.
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);
}
error which I got in this program is "ENTRY POINT MUST BE DEFINED"
Use Visual Studio wizard to generate a MFC app, it will set the project settings correctly for you.