WORDPAD 示例:Windows 应用程序

更新:2007 年 11 月

WORDPAD 是随 Windows 附带的字处理应用程序。它是使用 MFC 编写的完整字处理应用程序的示例。

WORDPAD 附带描述其用户界面的帮助文件。

安全说明:

提供该示例代码是为了阐释一个概念,并不代表着最安全的编码实践,因此不应在应用程序或网站中使用该示例代码。对于超出本示例代码的预期用途以外的使用所造成的偶然或继发性损失,Microsoft 不承担任何责任。

获取示例和安装示例的说明:

  • 在 Visual Studio 的“帮助”菜单上,单击“示例”。

    有关更多信息,请参见定位示例文件

  • 示例的最新版本和完整列表可以从 Visual Studio 2008 Samples page(Visual Studio 2008 示例页面)联机获取。

  • 还可以在计算机的硬盘上查找示例。默认情况下,示例和自述文件将复制到 \Program Files\Visual Studio 9.0\Samples\ 下的文件夹中。对于 Visual Studio 速成版,所有示例都位于联机位置。

生成并运行示例

生成并运行 WORDPAD 示例

  1. 打开解决方案 wordpad.sln。

  2. 在“生成”菜单中单击“生成”。

  3. 将 WordPad 作为独立的应用程序运行,以便它可以向系统注册其自身。

WORDPAD 功能

SUPERPAD 示例阐释基于 CEditView 类的基本字处理器。相反,WORDPAD 基于 CRichEditViewCRichEditDocCRichEditCntrItem 类,它除了支持 SUPERPAD 所支持的功能外,还演示了以下功能。

  • 能够读写多种文件格式并在多种文件格式之间进行转换,这些文件格式包括 Word 文件格式、.rtf(RTF 格式)格式和 ASCII 文本格式。

  • 文本格式设置,包括字体使用、字符格式设置(粗体、斜体、下划线)、颜色和磅值。这些属性在格式设置工具栏中提供。

  • 按段落设置格式,包括对齐方式(左对齐、居中对齐或右对齐)、制表符、边距和首行缩进。这些属性还在标尺工具栏中提供。

  • 撤消支持。

  • ActiveX 组件支持,包括容器和服务器。

关键字

此示例说明以下关键字:

AfxBeginThread、AfxFormatString1、AfxFormatString2、AfxGetApp、AfxGetAppName、AfxGetInstanceHandle、AfxGetMainWnd、AfxMessageBox、AfxOleGetMessageFilter、AfxOleInit、AfxOleSetUserCtrl、AfxRegisterClass、AfxRegisterWndClass、AfxThrowFileException、AfxThrowNotSupportedException、AfxThrowResourceException、BitBlt、CArchive::Close、CArchive::Read、CArchive::Write、CBrush::CreateSolidBrush、CButton::DrawItem、CComboBox::AddString、CComboBox::CompareItem、CComboBox::Create、CComboBox::DrawItem、CComboBox::FindString、CComboBox::FindStringExact、CComboBox::GetCount、CComboBox::GetCurSel、CComboBox::GetDroppedState、CComboBox::GetItemData、CComboBox::GetItemHeight、CComboBox::GetLBText、CComboBox::InsertString、CComboBox::LimitText、CComboBox::MeasureItem、CComboBox::ResetContent、CComboBox::SetCurSel、CComboBox::SetItemData、CComboBox::SetItemHeight、CComboBox::ShowDropDown、CControlBar::EnableDocking、CDC::Attach、CDC::BitBlt、CDC::CreateCompatibleDC、CDC::CreateIC、CDC::Detach、CDC::DrawFocusRect、CDC::DrawText、CDC::ExtTextOut、CDC::FillRect、CDC::GetBkColor、CDC::GetDeviceCaps、CDC::GetTextColor、CDC::GetTextExtent、CDC::GetTextMetrics、CDC::LineTo、CDC::MoveTo、CDC::Rectangle、CDC::RestoreDC、CDC::SaveDC、CDC::SelectObject、CDC::SetBkMode、CDC::SetTextColor、CDC::SetViewportOrg、CDC::TextOut、CDialog::Create、CDialog::DoModal、CDialog::EndDialog、CDialog::GetDefID、CDialog::InitModalIndirect、CDialog::OnInitDialog、CDialog::OnOK、CDialog::SetDefID、CDocTemplate::GetDocString、CDocument::GetFirstViewPosition、CDocument::GetNextView、CFile::Abort、CFile::Close、CFile::Flush、CFile::GetLength、CFile::GetPosition、CFile::GetStatus、CFile::LockRange、CFile::Open、CFile::Read、CFile::Seek、CFile::SeekToBegin、CFile::SetLength、CFile::UnlockRange、CFile::Write、CFileDialog::DoModal、CFont::CreateFontIndirect、CFrameWnd::ActivateFrame、CFrameWnd::Create、CFrameWnd::DockControlBar、CFrameWnd::EnableDocking、CFrameWnd::GetActiveDocument、CFrameWnd::GetActiveView、CFrameWnd::RecalcLayout、CFrameWnd::SetMessageText、CGdiObject::Attach、CGdiObject::CreateStockObject、CListBox::AddString、CListBox::GetCurSel、CListBox::SetCurSel、CMenu::AppendMenu、CMenu::CreatePopupMenu、CMenu::DeleteMenu、CMenu::Detach、CMenu::DrawItem、CMenu::FromHandle、CMenu::GetMenuItemCount、CMenu::GetSubMenu、CMenu::LoadMenu、CMenu::MeasureItem、CMenu::RemoveMenu、CMenu::TrackPopupMenu、CObject::AssertValid、CObject::Dump、CObject::Serialize、COleDataObject::Attach、COleDataObject::IsDataAvailable、COleDataSource::CacheData、COleDropTarget::Register、COleIPFrameWnd::OnCreateControlBars、COleIPFrameWnd::RepositionFrame、COleMessageFilter::EnableBusyDialog、COleResizeBar::Create、COleServerItem::GetClipboardData、COleServerItem::GetDocument、COleServerItem::OnDraw、COleServerItem::OnDrawEx、COleServerItem::OnGetExtent、COleStreamFile::OpenStream、COleTemplateServer::ConnectTemplate、CPalette::GetPaletteEntries、CPoint::Offset、CRect::BottomRight、CRect::CopyRect、CRect::Height、CRect::IntersectRect、CRect::OffsetRect、CRect::PtInRect、CRect::SetRect、CRect::SetRectEmpty、CRect::Size、CRect::TopLeft、CRect::Width、CStatusBar::Create、CStatusBar::SetIndicators、CString::Collate、CString::Empty、CString::FindOneOf、CString::GetBuffer、CString::GetBufferSetLength、CString::GetLength、CString::IsEmpty、CString::LoadString、CString::MakeUpper、CString::ReleaseBuffer、CString::Right、CToolBar::CommandToIndex、CToolBar::Create、CToolBar::GetItemRect、CToolBar::LoadBitmap、CToolBar::SetButtonInfo、CToolBar::SetButtons、CToolBar::SetSizes、CWinApp::ExitInstance、CWinApp::GetProfileInt、CWinApp::InitInstance、CWinApp::LoadIcon、CWinApp::LoadStdProfileSettings、CWinApp::OnDDECommand、CWinApp::OnFileNew、CWinApp::OnFileOpen、CWinApp::OpenDocumentFile、CWinApp::PreTranslateMessage、CWinApp::SetRegistryKey、CWinApp::WinHelp、CWinApp::WriteProfileInt、CWnd::BringWindowToTop、CWnd::CalcWindowRect、CWnd::CenterWindow、CWnd::ClientToScreen、CWnd::Create、CWnd::DestroyWindow、CWnd::DoDataExchange、CWnd::EnableWindow、CWnd::FromHandle、CWnd::GetCapture、CWnd::GetClientRect、CWnd::GetDlgCtrlID、CWnd::GetDlgItem、CWnd::GetFocus、CWnd::GetNextDlgTabItem、CWnd::GetOwner、CWnd::GetParent、CWnd::GetParentFrame、CWnd::GetSafeHwnd、CWnd::GetScrollPos、CWnd::GetStyle、CWnd::GetWindowPlacement、CWnd::GetWindowRect、CWnd::GetWindowTextLength、CWnd::Invalidate、CWnd::InvalidateRect、CWnd::IsChild、CWnd::IsWindowEnabled、CWnd::MoveWindow、CWnd::OnCommand、CWnd::OnCreate、CWnd::OnDestroy、CWnd::OnDevModeChange、CWnd::OnDropFiles、CWnd::OnEnable、CWnd::OnEraseBkgnd、CWnd::OnFontChange、CWnd::OnLButtonDown、CWnd::OnLButtonUp、CWnd::OnMouseMove、CWnd::OnMove、CWnd::OnPaletteChanged、CWnd::OnQueryNewPalette、CWnd::OnShowWindow、CWnd::OnSize、CWnd::OnSysColorChange、CWnd::OnWindowPosChanged、CWnd::OnWindowPosChanging、CWnd::PreCreateWindow、CWnd::PreTranslateMessage、CWnd::ScreenToClient、CWnd::SendMessage、CWnd::SetCapture、CWnd::SetDlgItemText、CWnd::SetFocus、CWnd::SetOwner、CWnd::SetWindowPos、CWnd::SetWindowText、CWnd::ShowWindow、CWnd::SubclassDlgItem、CWnd::UpdateWindow、CloseHandle、CommDlgExtendedError、CreateEvent、CreateFontIndirect、CreateILockBytesOnHGlobal、CreatePen、CreateSolidBrush、DeleteAtom、DeleteObject、DragAcceptFiles、DragFinish、DragQueryFile、EnumDateFormats、EnumFontFamilies、EnumTimeFormats、EnumWindows、FORMATETC、FindResource、FindWindow、FormatMessage、FreeLibrary、GetClassInfo、GetClassName、GetClientRect、GetClipboardData、GetDC、GetDateFormat、GetDeviceCaps、GetDlgItem、GetKeyState、GetLocalTime、GetLocaleInfo、GetModuleFileName、GetModuleHandle、GetObject、GetProcAddress、GetProfileInt、GetShortPathName、GetStockObject、GetSysColor、GetSystemMetrics、GetTextMetrics、GetTimeFormat、GetUserDefaultLCID、GetVersion、GetWindow、GetWindowText、GlobalAddAtom、GlobalAlloc、GlobalFree、GlobalGetAtomName、GlobalLock、GlobalSize、GlobalUnlock、HIWORD、InvalidateRect、KillTimer、LOWORD、LineTo、LoadBitmap、LoadCursor、LoadIcon、LoadLibrary、LoadString、MAKEINTRESOURCE、MAKELPARAM、MessageBeep、MoveTo、MsgWaitForMultipleObjects、MulDiv、OleInitialize、OleUninitialize、OpenFile、PeekMessage、PtInRect、RGB、ReadClassStg、RegCloseKey、RegCreateKey、RegOpenKey、RegQueryValueEx、RegSetValueEx、RegisterClipboardFormat、ReleaseCapture、ReleaseDC、ReleaseStgMedium、ResetEvent、RestoreDC、RoundRect、STGMEDIUM、SaveDC、SelectObject、SendMessage、SendMessageTimeout、SetEvent、SetFocus、SetForegroundWindow、SetROP2、SetRect、SetTimer、SetWindowPos、SetWindowText、ShellAbout、ShowWindow、StgCreateDocfileOnILockBytes、StgOpenStorage、WinHelp、div、isspace、lstrcat、lstrcmp、lstrcmpi、lstrcpy、lstrlen、max、memcmp、memcpy、memmove、memset、min、strcpy_s、wsprintf

说明:

某些示例(如此示例)尚未经过修改以反映 Visual C++ 向导、库和编译器中所做的更改,但仍演示了如何完成所需的任务。

请参见

其他资源

MFC 示例