#include <afxwin.h>#include "resource.h"class CSimplest : CWinApp...{public: virtual BOOL InitInstance();};CSimplest Simplest;class CMywnd:public CFrameWnd...{ CStatic *cs; CMenu *menu;public: CMywnd() ...{ Create(NULL,"simple mfc application"); cs=new CStatic(); cs->Create("hello",WS_CHILD|WS_VISIBLE|SS_CENTER,CRect(90,20,770,80),this); menu=new CMenu(); menu->LoadMenu(IDR_MENU1); SetMenu(menu); DrawMenuBar(); } void OnMenu(); DECLARE_MESSAGE_MAP()};class CMyDialog:public CDialog...{public: CMyDialog(CWnd * pPerantWnd=NULL):CDialog(IDD_DIALOG1,pPerantWnd)...{}};void CMywnd ::OnMenu()...{ CMyDialog mydialog(this); mydialog.DoModal();}BOOL CSimplest::InitInstance()...{ m_pMainWnd=new CMywnd(); m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); return true;}BEGIN_MESSAGE_MAP(CMywnd,CFrameWnd)ON_COMMAND(IDR_MENU2,OnMenu)ON_WM_CLOSE(OnMenu)END_MESSAGE_MAP()