Click to open or copy the MDIDOCVW project files.
The MDIDOCVW sample uses the framework's multiple-document interface (MDI) support and the document/view architecture. The sample contains two document types: Hello (which prints out a string in a view) and Bounce (which displays a bouncing ball of color in a view). MDIDOCVW also illustrates the Microsoft Windows timer, CColorDialog, CBitmap, and changing the default cursor of a window.
The MDIDOCVW sample provides a parent window with two distinct types of MDI child windows: a Bounce window, in which a ball bounces around; and a Hello window, which simply displays the text "Hello, World!"
Click New Bounce or New Hello on the File menu to create a new MDI child window. Both types of MDI child windows determine what menus are shown when they are active. Both types of windows have a Color menu. When you choose a color from this menu, the color of the bouncing ball or of the Hello text is updated. Click Custom to call a Color dialog box, from which you can select a custom color.
The Bounce window also has a Speed menu, from which you can select the speed the ball moves around the screen.
Although CBounceView and CHelloView both override Create, the override is not necessary to take advantage of the framework's MDI support. The override of Create, found in the CBounceView class, illustrates how to change the default cursor. Changing the default cursor of a window requires registering a new WNDCLASS by calling AfxRegisterWndClass and passing the name of the WNDCLASS in the call to Create.
The MDIDOCVW sample uses the document/view architecture. The application has two document types, Hello and Bounce, that demonstrate various MDI concepts.
A toolbar implements most of the menu commands. The toolbar also implements check-box buttons for the five basic colors.
This sample demonstrates the following keywords:
AfxRegisterWndClass; CBitmap::CreateCompatibleBitmap; CCmdUI::SetCheck; CColorDialog::DoModal; CColorDialog::GetColor; CDC::BitBlt; CDC::CreateCompatibleDC; CDC::DeleteDC; CDC::DrawText; CDC::Ellipse; CDC::FillRect; CDC::GetDeviceCaps; CDC::SelectObject; CDC::SetBkColor; CDC::SetTextColor; CFrameWnd::LoadFrame; CFrameWnd::rectDefault; CGdiObject::DeleteObject; CMDIChildWnd::Create; CWinApp::InitInstance; CWnd::DestroyWindow; CWnd::GetClientRect; CWnd::GetCurrentMessage; CWnd::GetDC; CWnd::KillTimer; CWnd::MessageBox; CWnd::OnCreate; CWnd::OnSize; CWnd::OnTimer; CWnd::ReleaseDC; CWnd::SetTimer; CWnd::ShowWindow; CWnd::UpdateWindow; GetSysColor; LOWORD; RGB; max; min