WORDPAD 範例:Windows 應用程式

更新:2007 年 11 月

WORDPAD 是包含在 Windows 中的文書處理應用程式,這是一個使用 MFC 撰寫的完整功能文書處理應用程式範例。

WORDPAD 隨附有一個說明使用者介面的說明檔案。

安全性注意事項:

這個程式碼範例僅供概念說明之用,同時因為範例中的程式碼撰寫並沒有周全的顧及所有安全性問題,所以本範例不適用於實際執行的應用程式或網站中。如果使用者擅自將範例程式碼用於其他意圖而導致連帶事件或重大損害時,Microsoft 將不承擔任何責任。

若要取得範例和指示以便進行安裝:

  • 按一下 Visual Studio [說明] 功能表上的 [範例]。

    如需詳細資訊,請參閱尋找範例檔案

  • 最新版的完整範例清單可從 Visual Studio 2008 範例網頁 (英文) 取得。

  • 您也可以將範例置於電腦硬碟中。根據預設,範例和讀我檔案都會複製到 \Program Files\Visual Studio 9.0\Samples\ 下的資料夾中。對於所有的 Visual Studio Express 版,所有範例都可在線上找到。

建置和執行範例

若要建置並執行 WORDPAD 範例

  1. 開啟 wordpad.sln 方案。

  2. 在 [建置] 功能表上按一下 [建置]。

  3. 將 WordPad 當做獨立的應用程式執行一次,讓 WordPad 把自己登錄到系統中。

WORDPAD 功能

SUPERPAD 範例會說明一個 CEditView 類別架構的基本文字處理器。相反地,WORDPAD 屬於 CRichEditViewCRichEditDocCRichEditCntrItem 類別架構,而且除了支援 SUPERPAD 所支援的功能,還會示範下列功能。

  • 在多種檔案格式 (其中包含 Word 檔案格式、.rtf (Rich Text Format) 格式和 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 範例