SUPERPAD: Demonstrates a Visual Editing Server That Edits Text Using CEditView

Click to open or copy the SUPERPAD project files.

The SUPERPAD sample illustrates how to use the CEditView class in conjunction with Visual Editing server support.

The MULTIPAD sample provides a simple illustration of how to use CEditView. In contrast, SUPERPAD illustrates advanced uses of CEditView through class derivation, including toggling the word wrap state of the edit control and changing the screen and printer font.

SUPERPAD also illustrates a wide variety of Microsoft Foundation Class Library (MFC) programming techniques.

To use SUPERPAD as a Visual Editing server, run it once as a stand-alone application so that it registers itself with Microsoft Windows®.

When you first run SUPERPAD, it displays a splash window that looks like an About dialog box. It stays on the screen briefly and then vanishes after a time-out. To close the splash window, press any key or click the mouse.

SUPERPAD remembers its window position from the last time you ran it. It also remembers whether the document window was maximized in the MDI frame window.

SUPERPAD Menus

The File menu offers standard commands — New, Open, Close, Save, Save As, Print, Print Preview, Print Setup, the most recently used (MRU) file list, and Exit.

The File menu also offers a Page Setup option you can use to specify a per-page header and/or footer. Leave the header or footer blank if you want none. You can specify any text in the header and footer. You can also specify any of the following formatting codes.

Like the simple MULTIPAD sample, SUPERPAD offers the following Edit menu commands, which are handled by default by CEditView: Cut, Copy, Page, Delete, Find. Find Next, Replace, Select All, and Undo. The Edit menu also offers a Word Wrap command to turn word wrapping on or off.

The View menu offers the following commands, which exercise various features of CEditView:

SUPERPAD Classes

SUPERPAD derives its view class CPadView from CEditView. CPadView accesses the attributes and operations of CEditView to add to the functionality of CEditView, as described here.

CPadView calls CEditView::SetFont and SetPrinterFont to initialize and change the screen and printer fonts.

To implement the Edit Word Wrap command, CPadView toggles the state of word wrapping by creating a new edit control (whose WNDCLASS is the standard Windows "edit" control). It toggles the ES_AUTOHSCROLL and WS_HSCROLL styles of the control, which together determine whether an edit control does word wrapping. CPadView saves the buffer of the old edit control and moves it into the new edit control. Finally, it destroys the old edit control and then associates the hWnd of the new edit control with the CPadView class by calling CWnd::SubclassWindow.

CPadView overrides OnPrint to add page headers and footers. It overrides OnBeginPrinting to set the current time, which is optionally displayed in the header, in the footer, or in both. It starts print preview at the current selection in the edit control.

CPadView overrides CView::OnScrollTo to scroll the view to the same position as last viewed during print preview.

This sample demonstrates the following keywords:

AfxGetApp; AfxGetInstanceHandle; AfxMessageBox; AfxOleInit; CArchive::Flush; CArchive::GetFile; CArchive::IsStoring; CBitmap::CreateCompatibleBitmap; CButton::DrawItem; CCmdUI::SetCheck; CDC::Attach; CDC::CreateCompatibleDC; CDC::Detach; CDC::DrawIcon; CDC::FillRect; CDC::GetDeviceCaps; CDC::GetTextMetrics; CDC::IntersectClipRect; CDC::LPtoHIMETRIC; CDC::LineTo; CDC::MoveTo; CDC::Rectangle; CDC::RestoreDC; CDC::SaveDC; CDC::SelectObject; CDC::SetBkMode; CDC::SetWindowExt; CDC::SetWindowOrg; CDC::StretchBlt; CDC::TextOut; CDialog::Create; CDialog::DoModal; CDialog::OnInitDialog; CDocTemplate::SetServerInfo; CDocument::DeleteContents; CDocument::GetFirstViewPosition; CDocument::GetNextView; CEditView::GetEditCtrl; CEditView::GetPrinterFont; CEditView::PrintInsideRect; CEditView::SerializeRaw; CEditView::SetPrinterFont; CEditView::SetTabStops; CEditView::dwStyleDefault; CFile::Write; CFont::CreateFontIndirect; CFontDialog::DoModal; CFrameWnd::ActivateFrame; CFrameWnd::Create; CFrameWnd::LoadFrame; CGdiObject::CreateStockObject; CGdiObject::DeleteObject; CGdiObject::GetObject; CObject::AssertValid; CObject::Dump; CObject::IsKindOf; CObject::Serialize; COleIPFrameWnd::OnCreateControlBars; COleLinkingDoc::OnGetLinkedItem; COleResizeBar::Create; COleServerDoc::IsInPlaceActive; COleServerDoc::OnDeactivateUI; COleServerDoc::OnGetEmbeddedItem; COleServerDoc::UpdateAllItems; COleServerItem::CopyToClipboard; COleServerItem::GetDataSource; COleServerItem::GetDocument; COleServerItem::OnDraw; COleServerItem::OnGetExtent; COleServerItem::OnRenderFileData; COleServerItem::OnShow; COleServerItem::SetItemName; COleTemplateServer::ConnectTemplate; COleTemplateServer::UpdateRegistry; CPrintDialog::CreatePrinterDC; CPrintInfo::SetMaxPage; CRect::Height; CRect::InflateRect; CRect::IsRectEmpty; CRect::SetRect; CRect::Size; CRect::Width; CStatusBar::Create; CStatusBar::SetIndicators; CString::Find; CString::GetBuffer; CString::GetLength; CString::IsEmpty; CString::Left; CString::LoadString; CString::Mid; CString::ReleaseBuffer; CTime::Format; CToolBar::Create; CToolBar::LoadBitmap; CToolBar::SetButtons; CView::GetDocument; CView::OnBeginPrinting; CView::OnPrepareDC; CView::OnPrint; CWinApp::AddDocTemplate; CWinApp::Enable3dControls; CWinApp::EnableShellOpen; CWinApp::ExitInstance; CWinApp::GetProfileInt; CWinApp::GetProfileString; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::OnIdle; CWinApp::PreTranslateMessage; CWinApp::RegisterShellFileTypes; CWinApp::WriteProfileInt; CWinApp::WriteProfileString; CWnd::BringWindowToTop; CWnd::CenterWindow; CWnd::DestroyWindow; CWnd::Detach; CWnd::DoDataExchange; CWnd::FromHandle; CWnd::GetClientRect; CWnd::GetDC; CWnd::GetDlgCtrlID; CWnd::GetFocus; CWnd::GetFont; CWnd::GetParent; CWnd::GetParentFrame; CWnd::GetStyle; CWnd::GetSuperWndProcAddr; CWnd::GetWindowPlacement; CWnd::GetWindowRect; CWnd::GetWindowText; CWnd::GetWindowTextLength; CWnd::IsZoomed; CWnd::KillTimer; CWnd::OnClose; CWnd::OnCreate; CWnd::OnEraseBkgnd; CWnd::OnRButtonDown; CWnd::OnSize; CWnd::OnTimer; CWnd::PreCreateWindow; CWnd::ReleaseDC; CWnd::ScreenToClient; CWnd::SendMessage; CWnd::SetDlgCtrlID; CWnd::SetDlgItemText; CWnd::SetFocus; CWnd::SetFont; CWnd::SetOwner; CWnd::SetTimer; CWnd::SetWindowPlacement; CWnd::SetWindowPos; CWnd::SetWindowText; CWnd::ShowWindow; CWnd::SubclassDlgItem; CWnd::SubclassWindow; CWnd::UpdateWindow; CreateWindow; DragAcceptFiles; GetCurrentTime; GetObject; GetProfileInt; GetProfileString; GetStockObject; GetSystemMetrics; GlobalMemoryStatus; IsIconic; IsWindowVisible; LOWORD; LoadIcon; MulDiv; SetWindowLong; SetWindowPos; UpdateWindow; WideCharToMultiByte; WriteProfileString; _alloca; _getdrive; lstrcpyn; lstrlen; min; wcstombs; wsprintf