#includeclass CMyFrameWnd : public CFrameWnd { public: CMyFrameWnd() { Create(nullptr, L"My First MFC Window"); } }; int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { CMyFrameWnd MyFrameWnd; MyFrameWnd.ShowWindow(nShowCmd); MyFrameWnd.UpdateWindow(); MSG msg; while (GetMessageW(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessageW(&msg); } return msg.wParam; }
#includeclass CMyFrameWnd : public CFrameWnd { public: CMyFrameWnd() { Create(nullptr, L"My MFC Window with Toolbar"); HINSTANCE hInst = AfxGetInstanceHandle(); EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); Verify( m_wndToolBar.LoadToolBar(IDR_MAINFRAME)); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); } private: CToolBar m_wndToolBar; }; int WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd ) { CMyFrameWnd MyFrameWnd; MyFrameWnd.ShowWindow(nShowCmd); MyFrameWnd.UpdateWindow(); MSG msg; while (GetMessageW(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessageW(&msg); } return msg.wParam; }
#includePackage library: MFC (Microsoft Foundation Class) Framework.class CMyFrameWnd : public CFrameWnd { public: CMyFrameWnd() { Create(nullptr, L"My MFC Window with Status Bar"); HINSTANCE hInst = AfxGetInstanceHandle(); EnableDocking(CBRS_ALIGN_ANY); m_wndStatusBar.Create(this); m_wndStatusBar.SetIndicators(statusIndicators, 2); CString str; str.LoadStringW(IDS_STATUS_STRING); m_wndStatusBar.SetPaneText(0, str.GetString()); } private: CStatusBar m_wndStatusBar; static UINT statusIndicators[2]; }; UINT CMyFrameWnd::statusIndicators[2] = { ID_SEPARATOR, IDS_STATUS_STRING }; int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { CMyFrameWnd MyFrameWnd; MyFrameWnd.ShowWindow(nShowCmd); MyFrameWnd.UpdateWindow(); MSG msg; while (GetMessageW(&msg, nullptr, 0, 0)) { TranslateMessage(&msg); DispatchMessageW(&msg); } return msg.wParam; }