├── .gitignore ├── README.md ├── buttondi.cpp ├── buttondi.h ├── chicdial.cpp ├── chicdial.h ├── cntritem.cpp ├── cntritem.h ├── colorlis.cpp ├── colorlis.h ├── datedial.cpp ├── datedial.h ├── ddxm.cpp ├── ddxm.h ├── docopt.cpp ├── docopt.h ├── doctype.cpp ├── doctype.h ├── filenewd.cpp ├── filenewd.h ├── formatba.cpp ├── formatba.h ├── formatpa.cpp ├── formatpa.h ├── formatta.cpp ├── formatta.h ├── helpids.h ├── ipframe.cpp ├── ipframe.h ├── key.cpp ├── key.h ├── license.txt ├── listdlg.cpp ├── listdlg.h ├── mainfrm.cpp ├── mainfrm.h ├── mswd6_32.h ├── mswrd632.wpc ├── multconv.cpp ├── multconv.h ├── options.cpp ├── options.h ├── optionsh.cpp ├── optionsh.h ├── pageset.cpp ├── pageset.h ├── penwin.h ├── res ├── font.bmp ├── formatba.bmp ├── formatbg.bmp ├── main1.bmp ├── main1b.bmp ├── mainfrm.bmp ├── mainfrmb.bmp ├── rtfdoc.ico ├── rulerbl.bmp ├── rulerblm.bmp ├── rulerdo.bmp ├── rulerdom.bmp ├── rulerta.bmp ├── rulertam.bmp ├── rulerup.bmp ├── rulerupm.bmp ├── srvr.bmp ├── srvrbig.bmp ├── textdoc.ico ├── wordp48.bmp ├── wordpad.ico ├── wordpad.rc2 └── write.ico ├── resource.h ├── ruler.cpp ├── ruler.h ├── splash.cpp ├── splash.h ├── srvritem.cpp ├── srvritem.h ├── stdafx.cpp ├── stdafx.h ├── strings.cpp ├── strings.h ├── targetver.h ├── unitspag.cpp ├── unitspag.h ├── wordpad.cpp ├── wordpad.h ├── wordpad.rc ├── wordpad.sln ├── wordpad.vcxproj ├── wordpad.vcxproj.filters ├── wordpdoc.cpp ├── wordpdoc.h ├── wordpvw.cpp ├── wordpvw.h └── write32.wpc /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio. 3 | ################################################################################ 4 | 5 | /.vs 6 | /amd64 7 | /Debug 8 | /Release 9 | 10 | *.user 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WORDPAD Sample: The Windows Application 2 | 3 | WORDPAD is the word processing application included with Windows. It is an example of a full-fledged word processing application written using MFC. 4 | 5 | WORDPAD comes with a help file describing its user interface. 6 | 7 | ### Security Note 8 | This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. 9 | 10 | ## Building and Running the Sample 11 | 12 | ### To build and run the WORDPAD sample 13 | 14 | 1. Open the solution wordpad.sln. 15 | 16 | 2. On the **Build** menu, click **Build**. 17 | 18 | 3. Run WordPad as a stand-alone application so it can register itself with the system. 19 | 20 | ## WORDPAD Features 21 | 22 | The SUPERPAD sample illustrates a basic word processor based on the **CEditView** class. In contrast, WORDPAD is based on the **CRichEditView**, **CRichEditDoc**, and **CRichEditCntrItem** classes, and — besides supporting the features that SUPERPAD supports — also demonstrates the following features. 23 | 24 | * The ability to read, write, and convert between multiple file formats, including the Word file format, .rtf (Rich Text Format) format, and ASCII text format. 25 | 26 | * Text formatting, including the use of fonts, character formatting (bold, italics, underlining), color, and point sizes. These attributes are available in a formatting toolbar. 27 | 28 | * Per-paragraph formatting, including alignment (left, center, or right), tabs, margins, and first-line indentation. These attributes are also available in a ruler toolbar. 29 | 30 | * Undo support. 31 | 32 | * ActiveX component support, both container and server. 33 | 34 | ## Keywords 35 | 36 | This sample demonstrates the following keywords: 37 | 38 | 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; wsprintf 39 | 40 | ### Note 41 | Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task. 42 | 43 | © Microsoft Corporation. All rights reserved. -------------------------------------------------------------------------------- /buttondi.cpp: -------------------------------------------------------------------------------- 1 | // buttondi.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "resource.h" 14 | #include "buttondi.h" 15 | #include "strings.h" 16 | #include "wordpad.h" 17 | 18 | #ifdef _DEBUG 19 | #undef THIS_FILE 20 | static char BASED_CODE THIS_FILE[] = __FILE__; 21 | #endif 22 | 23 | #ifndef DS_CONTEXTHELP 24 | #define DS_CONTEXTHELP 0x2000L 25 | #endif 26 | 27 | static const int nFontSize = 10; 28 | 29 | ///////////////////////////////////////////////////////////////////////////// 30 | // CButtonDialog dialog 31 | 32 | INT_PTR CButtonDialog::DisplayMessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, 33 | LPCTSTR lpszButtons, WORD wStyle, int nDef, int nCancel, 34 | DWORD* pHelpIDs, CWnd* pParentWnd) 35 | { 36 | CButtonDialog dlg(lpszText, lpszCaption, lpszButtons, wStyle, pHelpIDs, 37 | pParentWnd); 38 | dlg.SetDefault(nDef); 39 | dlg.SetCancel(nCancel); 40 | return dlg.DoModal(); 41 | } 42 | 43 | CButtonDialog::CButtonDialog(LPCTSTR lpszText, LPCTSTR lpszCaption, 44 | LPCTSTR lpszButtons, WORD wStyle, DWORD* pHelpIDs , 45 | CWnd* pParentWnd) : CCSDialog() 46 | { 47 | 48 | ASSERT(lpszText != NULL); 49 | ASSERT(lpszCaption != NULL); 50 | if (HIWORD(lpszText) == NULL) 51 | VERIFY(m_strText.LoadString(LOWORD((DWORD)(DWORD_PTR)lpszText))); 52 | else 53 | m_strText = lpszText; 54 | if (HIWORD(lpszCaption) == NULL) 55 | VERIFY(m_strCaption.LoadString(LOWORD((DWORD)(DWORD_PTR)lpszCaption))); 56 | else 57 | m_strCaption = lpszCaption; 58 | if (lpszButtons != NULL) 59 | AddButtons(lpszButtons); 60 | 61 | m_pParentWnd = pParentWnd; 62 | m_nDefButton = 0; 63 | m_nCancel = -1; 64 | m_pButtons = NULL; 65 | m_wStyle = wStyle; 66 | m_nBaseID = nFontSize; // don't use IDOK, IDCANCEL, etc 67 | m_hDlgTmp = NULL; 68 | 69 | LOGFONT lf; 70 | memcpy_s(&lf, sizeof(LOGFONT), &theApp.m_lf, sizeof(LOGFONT)); 71 | lf.lfHeight = -nFontSize; 72 | lf.lfWidth = 0; 73 | lf.lfWeight = FW_NORMAL; 74 | VERIFY(m_font.CreateFontIndirect(&lf)); 75 | 76 | // m_font.CreateFont(-nFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 77 | // FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, 78 | // DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, szFontName); 79 | m_pHelpIDs = pHelpIDs; 80 | } 81 | 82 | CButtonDialog::~CButtonDialog() 83 | { 84 | delete [] m_pButtons; 85 | if (m_hDlgTmp != NULL) 86 | GlobalFree(m_hDlgTmp); 87 | } 88 | 89 | BEGIN_MESSAGE_MAP(CButtonDialog, CCSDialog) 90 | //{{AFX_MSG_MAP(CButtonDialog) 91 | ON_WM_CREATE() 92 | //}}AFX_MSG_MAP 93 | END_MESSAGE_MAP() 94 | 95 | ///////////////////////////////////////////////////////////////////////////// 96 | // CButtonDialog message handlers 97 | 98 | int CButtonDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) 99 | { 100 | if (m_pHelpIDs != NULL) 101 | { 102 | for (int i=0;istyle = DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | 174 | WS_CAPTION | WS_SYSMENU; 175 | if (theApp.m_bWin4) 176 | lpDlgTmp->style |= DS_CONTEXTHELP; 177 | lpDlgTmp->dwExtendedStyle = 0; 178 | lpDlgTmp->cdit = 0; 179 | lpDlgTmp->x = 0; 180 | lpDlgTmp->y = 0; 181 | lpDlgTmp->cx = 100; 182 | lpDlgTmp->cy = 100; 183 | 184 | LPWSTR lpStr = (LPWSTR)(lpDlgTmp + 1); /* Move ptr to the variable fields */ 185 | 186 | *lpStr++ = 0; /* No Menu resource for Message Box */ 187 | *lpStr++ = 0; /* No Class name for MessageBox */ 188 | 189 | int nLen = m_strCaption.GetLength(); 190 | wcscpy_s(lpStr, sizeof(DLGTEMPLATE), CT2CW(m_strCaption)); 191 | 192 | lpStr += nLen+1; 193 | WORD* pWord = (WORD*)lpStr; 194 | *pWord = 10; // 10 pt font 195 | pWord++; 196 | lpStr = (LPWSTR) pWord; 197 | 198 | wcscpy_s(lpStr, sizeof(DLGTEMPLATE),CT2W(theApp.m_lf.lfFaceName)); 199 | } 200 | 201 | ///////////////////////////////////////////////////////////////////////////// 202 | // CButtonDialog overridables 203 | 204 | BOOL CButtonDialog::OnCommand(WPARAM wParam, LPARAM /*lParam*/) 205 | { 206 | if (wParam == IDCANCEL && m_nCancel != -1) 207 | { 208 | EndDialog(m_nCancel); 209 | return TRUE; 210 | } 211 | if (::GetDlgItem(m_hWnd, (int)wParam)==NULL) 212 | return FALSE; 213 | EndDialog((int)wParam-m_nBaseID); 214 | return TRUE; 215 | } 216 | 217 | INT_PTR CButtonDialog::DoModal() 218 | { 219 | ASSERT(m_strArray.GetSize() != 0); 220 | if (m_strArray.GetSize() == 0) 221 | return (m_nCancel != -1) ? m_nCancel : 0; 222 | 223 | // compute size of header 224 | // Fixed portions of DLG template header = sizeof(DLGTEMPLATE); 225 | // One null byte for menu name and one for class name = 2 226 | // Caption text plus NULL = m_strCaption.GetLength()+1 227 | int nSize = sizeof(DLGTEMPLATE); 228 | nSize += (2 + m_strCaption.GetLength()+1+lstrlen(theApp.m_lf.lfFaceName)+1)*2 +sizeof(WORD); 229 | m_hDlgTmp = GlobalAlloc(GPTR, nSize); 230 | if (m_hDlgTmp == NULL) 231 | return IDCANCEL; 232 | LPDLGTEMPLATE lpDlgTmp = (LPDLGTEMPLATE)GlobalLock(m_hDlgTmp); 233 | FillInHeader(lpDlgTmp); 234 | GlobalUnlock(m_hDlgTmp); 235 | InitModalIndirect(m_hDlgTmp); 236 | 237 | return CCSDialog::DoModal(); 238 | } 239 | 240 | ///////////////////////////////////////////////////////////////////////////// 241 | // CButtonDialog implementation 242 | 243 | void CButtonDialog::PositionControls() 244 | { 245 | CSize sizeBase = GetBaseUnits(); 246 | int nButtonHeight = (sizeBase.cy*14)/8; 247 | int nHeight = 0; 248 | int nSep,nLeftMargin,nRightMargin,nTopMargin,nBottomMargin; 249 | int nButtonAdj; 250 | int nWidth = 0; 251 | CRect rectText; 252 | 253 | // a) 5/8 screen Width 254 | // b) Caption 255 | // c) nLeftMargin ICON nSep TEXT nRightMargin 256 | // d) nLeftMargin Button1 nSep Button2 ... nRightMargin 257 | // client width is max(b,d, min(c,a)) 258 | 259 | CSize sizeIcon(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); 260 | nSep = sizeIcon.cx/2; 261 | nLeftMargin = nSep; 262 | nRightMargin = nSep; 263 | nTopMargin = nSep; 264 | nBottomMargin = nSep; 265 | 266 | CClientDC dc(this); 267 | CFont* pOldFont = dc.SelectObject(&m_font); 268 | 269 | nButtonAdj = dc.GetTextExtent(_T("XXX"),3).cx; // padding on buttons 270 | 271 | int nScreenWidth58 = dc.GetDeviceCaps(HORZRES)*5/8; 272 | int nCaptionWidth = dc.GetTextExtent(m_strCaption, m_strCaption. 273 | GetLength()).cx; 274 | CSize sizeText = dc.GetTextExtent(m_strText,m_strText.GetLength()); 275 | int nTextIconWidth = nLeftMargin+sizeIcon.cx+nSep+sizeText.cx+nRightMargin; 276 | INT_PTR nButtons = m_strArray.GetSize(); 277 | int nButtonsWidth = (int)(nLeftMargin+nRightMargin+(nButtons-1)*nSep); 278 | INT_PTR i; 279 | for (i=0;i nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep) 294 | { 295 | sizeText.cx = nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep; 296 | // int nTextWidth = nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep; 297 | // rectText.SetRect(0, 0, nTextWidth, 32767); 298 | rectText.SetRect(0, 0, sizeText.cx, 32767); 299 | /* Ask DrawText for the right cy */ 300 | sizeText.cy = dc.DrawText(m_strText, m_strText.GetLength(), &rectText, 301 | DT_CALCRECT | DT_WORDBREAK | DT_EXPANDTABS | DT_NOPREFIX); 302 | } 303 | 304 | m_staticText.SetWindowPos(NULL, nSep+sizeIcon.cx+nSep, nTopMargin, 305 | sizeText.cx, sizeText.cy, SWP_NOZORDER); 306 | 307 | sizeText.cy = max(sizeText.cy, sizeIcon.cy); // at least icon height 308 | nHeight = nTopMargin + sizeText.cy + nSep + nButtonHeight + nBottomMargin; 309 | 310 | CRect rect; 311 | rect.left = (nWidth - (nButtonsWidth - nLeftMargin - nRightMargin))/2; 312 | rect.top = nTopMargin + sizeText.cy + nSep; 313 | rect.bottom = rect.top + nButtonHeight; 314 | 315 | for (i=0;iDeleteMenu(SC_CLOSE, MF_BYCOMMAND); 333 | } 334 | dc.SelectObject(pOldFont); 335 | } 336 | 337 | CSize CButtonDialog::GetBaseUnits() 338 | { 339 | CDisplayIC dc; 340 | CFont* pFont = dc.SelectObject(&m_font); 341 | TEXTMETRIC tm; 342 | VERIFY(dc.GetTextMetrics(&tm)); 343 | dc.SelectObject(pFont); 344 | return CSize(tm.tmAveCharWidth, tm.tmHeight); 345 | } 346 | 347 | LPCTSTR CButtonDialog::GetIconID(WORD wFlags) 348 | { 349 | LPCTSTR lpszIcon = NULL; 350 | wFlags &= MB_ICONMASK; 351 | if (wFlags == MB_ICONHAND) 352 | lpszIcon = IDI_HAND; 353 | else if (wFlags == MB_ICONQUESTION) 354 | lpszIcon = IDI_QUESTION; 355 | else if (wFlags == MB_ICONEXCLAMATION) 356 | lpszIcon = IDI_EXCLAMATION; 357 | else if (wFlags == MB_ICONASTERISK) 358 | lpszIcon = IDI_ASTERISK; 359 | return lpszIcon; 360 | } 361 | -------------------------------------------------------------------------------- /buttondi.h: -------------------------------------------------------------------------------- 1 | // buttondi.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CButtonDialog dialog 14 | 15 | class CButtonDialog : public CCSDialog 16 | { 17 | // Construction 18 | public: 19 | CButtonDialog(LPCTSTR lpszText, LPCTSTR lpszCaption, LPCTSTR lpszButtons, 20 | WORD wStyle, DWORD* pHelpIDs = NULL, CWnd* pParentWnd = NULL); 21 | ~CButtonDialog(); 22 | 23 | // Attributes 24 | CFont m_font; 25 | // Operations 26 | static INT_PTR DisplayMessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, 27 | LPCTSTR lpszButtons, WORD wStyle, int nDef = 0, int nCancel = -1, 28 | DWORD* pHelpIDs = NULL, CWnd* pParentWnd = NULL); 29 | 30 | void AddButton(CString& strButton) { m_strArray.Add(strButton);} 31 | void AddButtons(LPCTSTR lpszButton); 32 | void SetCancel(int nCancel) 33 | { ASSERT(nCancel < m_strArray.GetSize()); m_nCancel = nCancel;} 34 | void SetDefault(int nDef) 35 | { ASSERT(nDef < m_strArray.GetSize()); m_nDefButton = nDef;} 36 | void FillInHeader(LPDLGTEMPLATE lpDlgTmp); 37 | 38 | // Overridables 39 | virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); 40 | virtual INT_PTR DoModal(); 41 | 42 | // Implementation 43 | protected: 44 | virtual const DWORD* GetHelpIDs() {return m_pHelpIDs;} 45 | DWORD* m_pHelpIDs; 46 | int m_nDefButton; 47 | int m_nCancel; 48 | HGLOBAL m_hDlgTmp; 49 | UINT m_nBaseID; 50 | WORD m_wStyle; 51 | CButton* m_pButtons; 52 | CStatic m_staticIcon; 53 | CStatic m_staticText; 54 | CString m_strCaption; 55 | CString m_strText; 56 | CStringArray m_strArray; 57 | CSize GetBaseUnits(); 58 | LPCTSTR GetIconID(WORD wFlags); 59 | void PositionControls(); 60 | 61 | // Generated message map functions 62 | //{{AFX_MSG(CButtonDialog) 63 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 64 | virtual BOOL OnInitDialog(); 65 | //}}AFX_MSG 66 | DECLARE_MESSAGE_MAP() 67 | }; 68 | -------------------------------------------------------------------------------- /chicdial.cpp: -------------------------------------------------------------------------------- 1 | // chicdial.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | 14 | #ifdef _DEBUG 15 | #undef THIS_FILE 16 | static char BASED_CODE THIS_FILE[] = __FILE__; 17 | #endif 18 | 19 | ///////////////////////////////////////////////////////////////////////////// 20 | // CCSDialog dialog 21 | 22 | CCSDialog::CCSDialog(UINT nIDTemplate, CWnd* pParentWnd) 23 | : CDialog(nIDTemplate, pParentWnd) 24 | { 25 | } 26 | 27 | CCSDialog::CCSDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd) 28 | : CDialog(lpszTemplateName, pParentWnd) 29 | { 30 | } 31 | 32 | CCSDialog::CCSDialog() : CDialog() 33 | { 34 | } 35 | 36 | BEGIN_MESSAGE_MAP(CCSDialog, CDialog) 37 | //{{AFX_MSG_MAP(CCSDialog) 38 | //}}AFX_MSG_MAP 39 | ON_MESSAGE(WM_HELP, OnHelp) 40 | ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu) 41 | END_MESSAGE_MAP() 42 | 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | // CCSDialog message handlers 46 | 47 | LONG_PTR CCSDialog::OnHelp(UINT_PTR, LONG_PTR lParam) 48 | { 49 | ::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, AfxGetApp()->m_pszHelpFilePath, 50 | HELP_WM_HELP, (ULONG_PTR)GetHelpIDs()); 51 | return 0; 52 | } 53 | 54 | LONG_PTR CCSDialog::OnHelpContextMenu(UINT_PTR wParam, LONG_PTR) 55 | { 56 | ::WinHelp((HWND)wParam, AfxGetApp()->m_pszHelpFilePath, 57 | HELP_CONTEXTMENU, (ULONG_PTR)GetHelpIDs()); 58 | return 0; 59 | } 60 | 61 | BOOL CCSDialog::OnInitDialog() 62 | { 63 | CDialog::OnInitDialog(); 64 | ModifyStyleEx(0, WS_EX_CONTEXTHELP); 65 | return TRUE; // return TRUE unless you set the focus to a control 66 | // EXCEPTION: OCX Property Pages should return FALSE 67 | } 68 | 69 | ///////////////////////////////////////////////////////////////////////////// 70 | // CCSPropertyPage 71 | 72 | CCSPropertyPage::CCSPropertyPage(UINT nIDTemplate, UINT nIDCaption) 73 | : CPropertyPage(nIDTemplate, nIDCaption) 74 | { 75 | } 76 | 77 | CCSPropertyPage::CCSPropertyPage(LPCTSTR lpszTemplateName, 78 | UINT nIDCaption) : CPropertyPage(lpszTemplateName, nIDCaption) 79 | { 80 | } 81 | 82 | BEGIN_MESSAGE_MAP(CCSPropertyPage, CPropertyPage) 83 | //{{AFX_MSG_MAP(CCSPropertyPage) 84 | //}}AFX_MSG_MAP 85 | ON_MESSAGE(WM_HELP, OnHelp) 86 | ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu) 87 | END_MESSAGE_MAP() 88 | 89 | 90 | ///////////////////////////////////////////////////////////////////////////// 91 | // CCSPropertyPage message handlers 92 | 93 | LONG_PTR CCSPropertyPage::OnHelp(UINT_PTR, LONG_PTR lParam) 94 | { 95 | ::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle, AfxGetApp()->m_pszHelpFilePath, 96 | HELP_WM_HELP, (ULONG_PTR)GetHelpIDs()); 97 | return 0; 98 | } 99 | 100 | LONG_PTR CCSPropertyPage::OnHelpContextMenu(UINT_PTR wParam, LONG_PTR) 101 | { 102 | ::WinHelp((HWND)wParam, AfxGetApp()->m_pszHelpFilePath, 103 | HELP_CONTEXTMENU, (ULONG_PTR)GetHelpIDs()); 104 | return 0; 105 | } 106 | 107 | ///////////////////////////////////////////////////////////////////////////// 108 | // CCSPropertySheet 109 | 110 | BEGIN_MESSAGE_MAP(CCSPropertySheet, CPropertySheet) 111 | //{{AFX_MSG_MAP(CCSPropertySheet) 112 | //}}AFX_MSG_MAP 113 | ON_MESSAGE(WM_HELP, OnHelp) 114 | ON_MESSAGE(WM_CONTEXTMENU, OnHelpContextMenu) 115 | END_MESSAGE_MAP() 116 | 117 | CCSPropertySheet::CCSPropertySheet(UINT nIDCaption, CWnd *pParentWnd, 118 | UINT iSelectPage) : CPropertySheet(nIDCaption, pParentWnd, iSelectPage) 119 | { 120 | } 121 | 122 | CCSPropertySheet::CCSPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd, 123 | UINT iSelectPage) : CPropertySheet(pszCaption, pParentWnd, iSelectPage) 124 | { 125 | } 126 | 127 | ///////////////////////////////////////////////////////////////////////////// 128 | // CCSPropertySheet message handlers 129 | 130 | LONG_PTR CCSPropertySheet::OnHelp(UINT_PTR wParam, LONG_PTR lParam) 131 | { 132 | GetActivePage()->SendMessage(WM_HELP, wParam, lParam); 133 | return 0; 134 | } 135 | 136 | LONG_PTR CCSPropertySheet::OnHelpContextMenu(UINT_PTR wParam, LONG_PTR lParam) 137 | { 138 | GetActivePage()->SendMessage(WM_CONTEXTMENU, wParam, lParam); 139 | return 0; 140 | } 141 | 142 | BOOL CCSPropertySheet::PreCreateWindow(CREATESTRUCT& cs) 143 | { 144 | cs.dwExStyle |= WS_EX_CONTEXTHELP; 145 | return CPropertySheet::PreCreateWindow(cs); 146 | } 147 | -------------------------------------------------------------------------------- /chicdial.h: -------------------------------------------------------------------------------- 1 | // chicdial.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CCSDialog dialog 14 | 15 | class CCSDialog : public CDialog 16 | { 17 | // Construction 18 | public: 19 | CCSDialog(); 20 | CCSDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL); 21 | CCSDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL); 22 | 23 | // Implementation 24 | protected: 25 | virtual const DWORD* GetHelpIDs() = 0; 26 | 27 | // Generated message map functions 28 | //{{AFX_MSG(CCSDialog) 29 | virtual BOOL OnInitDialog(); 30 | //}}AFX_MSG 31 | afx_msg LONG_PTR OnHelp(UINT_PTR wParam, LONG_PTR lParam); 32 | afx_msg LONG_PTR OnHelpContextMenu(UINT_PTR wParam, LONG_PTR lParam); 33 | DECLARE_MESSAGE_MAP() 34 | }; 35 | 36 | class CCSPropertyPage : public CPropertyPage 37 | { 38 | // Construction 39 | public: 40 | CCSPropertyPage(UINT nIDTemplate, UINT nIDCaption = 0); 41 | CCSPropertyPage(LPCTSTR lpszTemplateName, UINT nIDCaption = 0); 42 | 43 | // Implementation 44 | protected: 45 | virtual const DWORD* GetHelpIDs() = 0; 46 | 47 | // Generated message map functions 48 | //{{AFX_MSG(CCSPropertyPage) 49 | //}}AFX_MSG 50 | afx_msg LONG_PTR OnHelp(UINT_PTR wParam, LONG_PTR lParam); 51 | afx_msg LONG_PTR OnHelpContextMenu(UINT_PTR wParam, LONG_PTR lParam); 52 | DECLARE_MESSAGE_MAP() 53 | }; 54 | 55 | class CCSPropertySheet : public CPropertySheet 56 | { 57 | // Construction 58 | public: 59 | CCSPropertySheet(UINT nIDCaption, CWnd *pParentWnd = NULL, 60 | UINT iSelectPage = 0); 61 | CCSPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, 62 | UINT iSelectPage = 0); 63 | // Implementation 64 | protected: 65 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 66 | // Generated message map functions 67 | //{{AFX_MSG(CCSPropertySheet) 68 | //}}AFX_MSG 69 | afx_msg LONG_PTR OnHelp(UINT_PTR wParam, LONG_PTR lParam); 70 | afx_msg LONG_PTR OnHelpContextMenu(UINT_PTR wParam, LONG_PTR lParam); 71 | DECLARE_MESSAGE_MAP() 72 | }; 73 | -------------------------------------------------------------------------------- /cntritem.cpp: -------------------------------------------------------------------------------- 1 | // cntritem.cpp : implementation of the CWordPadCntrItem class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | 15 | #include "wordpdoc.h" 16 | #include "wordpvw.h" 17 | #include "cntritem.h" 18 | 19 | #ifdef _DEBUG 20 | #undef THIS_FILE 21 | static char BASED_CODE THIS_FILE[] = __FILE__; 22 | #endif 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // CWordPadCntrItem implementation 26 | 27 | IMPLEMENT_SERIAL(CWordPadCntrItem, CRichEditCntrItem, 0) 28 | 29 | CWordPadCntrItem::CWordPadCntrItem(REOBJECT *preo, CWordPadDoc* pContainer) 30 | : CRichEditCntrItem(preo, pContainer) 31 | { 32 | } 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | // CWordPadCntrItem diagnostics 36 | 37 | #ifdef _DEBUG 38 | void CWordPadCntrItem::AssertValid() const 39 | { 40 | CRichEditCntrItem::AssertValid(); 41 | } 42 | 43 | void CWordPadCntrItem::Dump(CDumpContext& dc) const 44 | { 45 | CRichEditCntrItem::Dump(dc); 46 | } 47 | #endif 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | -------------------------------------------------------------------------------- /cntritem.h: -------------------------------------------------------------------------------- 1 | // cntritem.h : interface of the CWordPadCntrItem class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | class CWordPadDoc; 13 | class CWordPadView; 14 | 15 | class CWordPadCntrItem : public CRichEditCntrItem 16 | { 17 | DECLARE_SERIAL(CWordPadCntrItem) 18 | 19 | // Constructors 20 | public: 21 | CWordPadCntrItem(REOBJECT* preo = NULL, CWordPadDoc* pContainer = NULL); 22 | // Note: pContainer is allowed to be NULL to enable IMPLEMENT_SERIALIZE. 23 | // IMPLEMENT_SERIALIZE requires the class have a constructor with 24 | // zero arguments. Normally, OLE items are constructed with a 25 | // non-NULL document pointer. 26 | 27 | // Attributes 28 | public: 29 | CWordPadDoc* GetDocument() 30 | { return (CWordPadDoc*)COleClientItem::GetDocument(); } 31 | CWordPadView* GetActiveView() 32 | { return (CWordPadView*)COleClientItem::GetActiveView(); } 33 | 34 | // ClassWizard generated virtual function overrides 35 | //{{AFX_VIRTUAL(CWordPadCntrItem) 36 | public: 37 | protected: 38 | //}}AFX_VIRTUAL 39 | 40 | // Implementation 41 | public: 42 | #ifdef _DEBUG 43 | virtual void AssertValid() const; 44 | virtual void Dump(CDumpContext& dc) const; 45 | #endif 46 | }; 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | -------------------------------------------------------------------------------- /colorlis.cpp: -------------------------------------------------------------------------------- 1 | // colorlis.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "colorlis.h" 15 | 16 | #ifdef _DEBUG 17 | #undef THIS_FILE 18 | static char BASED_CODE THIS_FILE[] = __FILE__; 19 | #endif 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | // CColorMenu 23 | 24 | /* 25 | int BASED_CODE CColorMenu::indexMap[17] = { 26 | 0, //black 27 | 19, //white 28 | 13, //red 29 | 14, //green 30 | 16, //blue 31 | 15, //yellow 32 | 17, //magenta 33 | 18, //cyan 34 | 1, //dark red 35 | 2, //dark green 36 | 4, //dark blue 37 | 3, //light brown 38 | 5, //purple 39 | 6, //dark cyan 40 | 7, //light gray 41 | 12, //gray 42 | 0}; //automatic 43 | */ 44 | 45 | int BASED_CODE CColorMenu::indexMap[17] = { 46 | 0, //black 47 | 1, //dark red 48 | 2, //dark green 49 | 3, //light brown 50 | 4, //dark blue 51 | 5, //purple 52 | 6, //dark cyan 53 | 12, //gray 54 | 7, //light gray 55 | 13, //red 56 | 14, //green 57 | 15, //yellow 58 | 16, //blue 59 | 17, //magenta 60 | 18, //cyan 61 | 19, //white 62 | 0}; //automatic 63 | 64 | CColorMenu::CColorMenu() 65 | { 66 | VERIFY(CreatePopupMenu()); 67 | ASSERT(GetMenuItemCount()==0); 68 | for (int i=0; i<=16;i++) 69 | VERIFY(AppendMenu(MF_OWNERDRAW, ID_COLOR0+i, (LPCTSTR)(INT_PTR)(ID_COLOR0+i))); 70 | } 71 | 72 | COLORREF CColorMenu::GetColor(UINT id) 73 | { 74 | ENSURE(id >= ID_COLOR0); 75 | ENSURE(id <= ID_COLOR16); 76 | if (id == ID_COLOR16) // autocolor 77 | return ::GetSysColor(COLOR_WINDOWTEXT); 78 | else 79 | { 80 | CPalette* pPal = CPalette::FromHandle( (HPALETTE) GetStockObject(DEFAULT_PALETTE)); 81 | ENSURE(pPal != NULL); 82 | PALETTEENTRY pe; 83 | if (pPal->GetPaletteEntries(indexMap[id-ID_COLOR0], 1, &pe) == 0) 84 | return ::GetSysColor(COLOR_WINDOWTEXT); 85 | else 86 | return RGB(pe.peRed,pe.peGreen,pe.peBlue); 87 | // return PALETTEINDEX(CColorMenu::indexMap[id-ID_COLOR0]); 88 | } 89 | } 90 | 91 | void CColorMenu::DrawItem(LPDRAWITEMSTRUCT lpDIS) 92 | { 93 | ASSERT(lpDIS->CtlType == ODT_MENU); 94 | UINT id = (UINT)(WORD)lpDIS->itemID; 95 | ASSERT(id == lpDIS->itemData); 96 | ASSERT(id >= ID_COLOR0); 97 | ASSERT(id <= ID_COLOR16); 98 | CDC dc; 99 | dc.Attach(lpDIS->hDC); 100 | 101 | CRect rc(lpDIS->rcItem); 102 | ASSERT(rc.Width() < 500); 103 | if (lpDIS->itemState & ODS_FOCUS) 104 | dc.DrawFocusRect(&rc); 105 | 106 | COLORREF cr = (lpDIS->itemState & ODS_SELECTED) ? 107 | ::GetSysColor(COLOR_HIGHLIGHT) : 108 | dc.GetBkColor(); 109 | 110 | CBrush brushFill(cr); 111 | cr = dc.GetTextColor(); 112 | 113 | if (lpDIS->itemState & ODS_SELECTED) 114 | dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT)); 115 | 116 | int nBkMode = dc.SetBkMode(TRANSPARENT); 117 | dc.FillRect(&rc, &brushFill); 118 | 119 | rc.left += 50; 120 | CString strColor; 121 | strColor.LoadString(id); 122 | dc.TextOut(rc.left,rc.top,strColor,strColor.GetLength()); 123 | rc.left -= 45; 124 | rc.top += 2; 125 | rc.bottom -= 2; 126 | rc.right = rc.left + 40; 127 | CBrush brush(GetColor(id)); 128 | CBrush* pOldBrush = dc.SelectObject(&brush); 129 | dc.Rectangle(rc); 130 | 131 | dc.SelectObject(pOldBrush); 132 | dc.SetTextColor(cr); 133 | dc.SetBkMode(nBkMode); 134 | 135 | dc.Detach(); 136 | } 137 | 138 | void CColorMenu::MeasureItem(LPMEASUREITEMSTRUCT lpMIS) 139 | { 140 | ASSERT(lpMIS->CtlType == ODT_MENU); 141 | UINT id = (UINT)(WORD)lpMIS->itemID; 142 | ASSERT(id == lpMIS->itemData); 143 | ASSERT(id >= ID_COLOR0); 144 | ASSERT(id <= ID_COLOR16); 145 | CDisplayIC dc; 146 | CString strColor; 147 | strColor.LoadString(id); 148 | CSize sizeText = dc.GetTextExtent(strColor,strColor.GetLength()); 149 | ASSERT(sizeText.cx < 500); 150 | lpMIS->itemWidth = sizeText.cx + 50; 151 | lpMIS->itemHeight = sizeText.cy; 152 | } 153 | -------------------------------------------------------------------------------- /colorlis.h: -------------------------------------------------------------------------------- 1 | // colorlis.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CColorMenu window 14 | 15 | class CColorMenu : public CMenu 16 | { 17 | // Construction 18 | public: 19 | CColorMenu(); 20 | 21 | // Attributes 22 | public: 23 | static int BASED_CODE indexMap[17]; 24 | static COLORREF GetColor(UINT id); 25 | 26 | // Operations 27 | public: 28 | 29 | // Implementation 30 | public: 31 | virtual void DrawItem(LPDRAWITEMSTRUCT lpDIS); 32 | virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMIS); 33 | 34 | }; 35 | 36 | ///////////////////////////////////////////////////////////////////////////// 37 | -------------------------------------------------------------------------------- /datedial.cpp: -------------------------------------------------------------------------------- 1 | // datedial.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "datedial.h" 15 | #include "helpids.h" 16 | #include 17 | 18 | #ifdef _DEBUG 19 | #undef THIS_FILE 20 | static char BASED_CODE THIS_FILE[] = __FILE__; 21 | #endif 22 | 23 | SYSTEMTIME CDateDialog::m_time; 24 | LCID CDateDialog::m_id; 25 | CListBox* CDateDialog::m_pListBox = NULL; 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | // CDateDialog dialog 29 | 30 | const DWORD CDateDialog::m_nHelpIDs[] = 31 | { 32 | IDC_DATEDIALOG_LIST, IDH_WORDPAD_TIMEDATE, 33 | IDC_STATIC_HEADING, IDH_WORDPAD_TIMEDATE, 34 | IDOK, IDH_WORDPAD_TIMEDATE, 35 | IDCANCEL, IDH_WORDPAD_TIMEDATE, 36 | 0 , 0 37 | }; 38 | 39 | CDateDialog::CDateDialog(CWnd* pParent /*=NULL*/) 40 | : CCSDialog(CDateDialog::IDD, pParent) 41 | { 42 | //{{AFX_DATA_INIT(CDateDialog) 43 | m_strSel = _T(""); 44 | //}}AFX_DATA_INIT 45 | } 46 | 47 | 48 | void CDateDialog::DoDataExchange(CDataExchange* pDX) 49 | { 50 | CCSDialog::DoDataExchange(pDX); 51 | //{{AFX_DATA_MAP(CDateDialog) 52 | DDX_Control(pDX, IDC_DATEDIALOG_LIST, m_listBox); 53 | DDX_LBString(pDX, IDC_DATEDIALOG_LIST, m_strSel); 54 | //}}AFX_DATA_MAP 55 | } 56 | 57 | 58 | BEGIN_MESSAGE_MAP(CDateDialog, CCSDialog) 59 | //{{AFX_MSG_MAP(CDateDialog) 60 | ON_LBN_DBLCLK(IDC_DATEDIALOG_LIST, OnDblclkDatedialogList) 61 | //}}AFX_MSG_MAP 62 | END_MESSAGE_MAP() 63 | 64 | 65 | ///////////////////////////////////////////////////////////////////////////// 66 | // CDateDialog message handlers 67 | 68 | BOOL CDateDialog::OnInitDialog() 69 | { 70 | CCSDialog::OnInitDialog(); 71 | 72 | m_pListBox = &m_listBox; // set static member 73 | GetLocalTime(&m_time); 74 | m_id = GetUserDefaultLCID(); 75 | 76 | EnumDateFormats(DateFmtEnumProc, m_id, DATE_SHORTDATE); 77 | EnumDateFormats(DateFmtEnumProc, m_id, DATE_LONGDATE); 78 | EnumTimeFormats(TimeFmtEnumProc, m_id, 0); 79 | 80 | m_pListBox = NULL; 81 | m_listBox.SetCurSel(0); 82 | 83 | return TRUE; // return TRUE unless you set the focus to a control 84 | // EXCEPTION: OCX Property Pages should return FALSE 85 | } 86 | 87 | BOOL CALLBACK CDateDialog::DateFmtEnumProc(LPTSTR lpszFormatString) 88 | { 89 | ENSURE(m_pListBox != NULL); 90 | TCHAR buf[256]; 91 | VERIFY(GetDateFormat(m_id, 0, &m_time, lpszFormatString, buf, 256)); 92 | // we can end up with same format because a format with leading 93 | // zeroes may be the same as one without when a number is big enough 94 | // e.g. 09/10/94 9/10/94 are different but 10/10/94 and 10/10/94 are 95 | // the same 96 | if (m_pListBox->FindStringExact(-1,buf) == CB_ERR) 97 | m_pListBox->AddString(buf); 98 | return TRUE; 99 | } 100 | 101 | BOOL CALLBACK CDateDialog::TimeFmtEnumProc(LPTSTR lpszFormatString) 102 | { 103 | ENSURE(m_pListBox != NULL); 104 | TCHAR buf[256]; 105 | VERIFY(GetTimeFormat(m_id, 0, &m_time, lpszFormatString, buf, 256)); 106 | // we can end up with same format because a format with leading 107 | // zeroes may be the same as one without when a number is big enough 108 | // e.g. 09/10/94 9/10/94 are different but 10/10/94 and 10/10/94 are 109 | // the same 110 | if (m_pListBox->FindStringExact(-1,buf) == CB_ERR) 111 | m_pListBox->AddString(buf); 112 | return TRUE; 113 | } 114 | 115 | void CDateDialog::OnDblclkDatedialogList() 116 | { 117 | OnOK(); 118 | } 119 | -------------------------------------------------------------------------------- /datedial.h: -------------------------------------------------------------------------------- 1 | // datedial.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CDateDialog dialog 14 | 15 | class CDateDialog : public CCSDialog 16 | { 17 | // Construction 18 | public: 19 | CDateDialog(CWnd* pParent = NULL); // standard constructor 20 | 21 | // Attributes 22 | static SYSTEMTIME m_time; 23 | static LCID m_id; 24 | static CListBox* m_pListBox; 25 | static BOOL CALLBACK DateFmtEnumProc(LPTSTR lpszFormatString); 26 | static BOOL CALLBACK TimeFmtEnumProc(LPTSTR lpszFormatString); 27 | 28 | // Dialog Data 29 | //{{AFX_DATA(CDateDialog) 30 | enum { IDD = IDD_DATEDIALOG }; 31 | CListBox m_listBox; 32 | CString m_strSel; 33 | //}}AFX_DATA 34 | 35 | 36 | // Overrides 37 | // ClassWizard generated virtual function overrides 38 | //{{AFX_VIRTUAL(CDateDialog) 39 | protected: 40 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 41 | //}}AFX_VIRTUAL 42 | 43 | // Implementation 44 | protected: 45 | static const DWORD m_nHelpIDs[]; 46 | virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} 47 | 48 | // Generated message map functions 49 | //{{AFX_MSG(CDateDialog) 50 | virtual BOOL OnInitDialog(); 51 | afx_msg void OnDblclkDatedialogList(); 52 | //}}AFX_MSG 53 | DECLARE_MESSAGE_MAP() 54 | }; 55 | -------------------------------------------------------------------------------- /ddxm.cpp: -------------------------------------------------------------------------------- 1 | // ddxm.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "ddxm.h" 14 | #include "wordpad.h" 15 | #include "resource.h" 16 | 17 | // this routine prints a floatingpoint number with 2 digits after the decimal 18 | void PASCAL DDX_Twips(CDataExchange* pDX, int nIDC, int& value) 19 | { 20 | HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); 21 | TCHAR szT[64]; 22 | 23 | if (pDX->m_bSaveAndValidate) 24 | { 25 | ::GetWindowText(hWndCtrl, szT, sizeof(szT)); 26 | if (szT[0] != NULL) // not empty 27 | { 28 | if (!theApp.ParseMeasurement(szT, value)) 29 | { 30 | AfxMessageBox(IDS_INVALID_MEASUREMENT,MB_OK|MB_ICONINFORMATION); 31 | pDX->Fail(); // throws exception 32 | } 33 | theApp.PrintTwips(szT, 64, value, 2); 34 | theApp.ParseMeasurement(szT, value); 35 | } 36 | else // empty 37 | value = INT_MAX; 38 | } 39 | else 40 | { 41 | // convert from twips to default units 42 | if (value != INT_MAX) 43 | { 44 | theApp.PrintTwips(szT, 64, value, 2); 45 | SetWindowText(hWndCtrl, szT); 46 | } 47 | } 48 | } 49 | 50 | void PASCAL DDV_MinMaxTwips(CDataExchange* pDX, int value, int minVal, int maxVal) 51 | { 52 | ASSERT(minVal <= maxVal); 53 | if (value < minVal || value > maxVal) 54 | { 55 | // "The measurement must be between %1 and %2." 56 | if (!pDX->m_bSaveAndValidate) 57 | { 58 | TRACE0("Warning: initial dialog data is out of range.\n"); 59 | return; // don't stop now 60 | } 61 | TCHAR szMin[64]; 62 | TCHAR szMax[64]; 63 | theApp.PrintTwips(szMin, 64, minVal, 2); 64 | theApp.PrintTwips(szMax, 64, maxVal, 2); 65 | CString prompt; 66 | AfxFormatString2(prompt, IDS_MEASUREMENT_RANGE, szMin, szMax); 67 | AfxMessageBox(prompt, MB_ICONEXCLAMATION, AFX_IDS_APP_TITLE); 68 | prompt.Empty(); // exception prep 69 | pDX->Fail(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ddxm.h: -------------------------------------------------------------------------------- 1 | // This is a part of the Microsoft Foundation Classes C++ library. 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // This source code is only intended as a supplement to the 5 | // Microsoft Foundation Classes Reference and related 6 | // electronic documentation provided with the library. 7 | // See these sources for detailed information regarding the 8 | // Microsoft Foundation Classes product. 9 | 10 | #include 11 | void PASCAL DDX_Twips(CDataExchange* pDX, int nIDC, int& value); 12 | void PASCAL DDV_MinMaxTwips(CDataExchange* pDX, int value, int minVal, int maxVal); 13 | #define DDXM_BLANK INT_MAX 14 | -------------------------------------------------------------------------------- /docopt.cpp: -------------------------------------------------------------------------------- 1 | // docopt.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "docopt.h" 15 | #include "helpids.h" 16 | 17 | #ifdef _DEBUG 18 | #undef THIS_FILE 19 | static char BASED_CODE THIS_FILE[] = __FILE__; 20 | #endif 21 | 22 | ///////////////////////////////////////////////////////////////////////////// 23 | // CDocOptPage property page 24 | 25 | const DWORD CDocOptPage::m_nHelpIDs[] = 26 | { 27 | IDC_BOX, IDH_COMM_GROUPBOX, 28 | IDC_WRAP_NONE, IDH_WORDPAD_WRAP_NO, 29 | IDC_WRAP_WINDOW, IDH_WORDPAD_WRAP_WINDOW, 30 | IDC_WRAP_RULER, IDH_WORDPAD_WRAP_RULER, 31 | IDC_BOXT, IDH_COMM_GROUPBOX, 32 | IDC_CHECK_TOOLBAR, IDH_WORDPAD_CHECK_TOOLBAR, 33 | IDC_CHECK_FORMATBAR, IDH_WORDPAD_CHECK_FORMATBAR, 34 | IDC_CHECK_STATUSBAR, IDH_WORDPAD_CHECK_STATUSBAR, 35 | IDC_CHECK_RULERBAR, IDH_WORDPAD_CHECK_RULERBAR, 36 | 0, 0 37 | }; 38 | 39 | CDocOptPage::CDocOptPage() : CCSPropertyPage(CDocOptPage::IDD) 40 | { 41 | //{{AFX_DATA_INIT(CDocOptPage) 42 | m_nWordWrap = -1; 43 | m_bFormatBar = FALSE; 44 | m_bRulerBar = FALSE; 45 | m_bStatusBar = FALSE; 46 | m_bToolBar = FALSE; 47 | //}}AFX_DATA_INIT 48 | } 49 | 50 | CDocOptPage::CDocOptPage(UINT nIDCaption) : 51 | CCSPropertyPage(CDocOptPage::IDD, nIDCaption) 52 | { 53 | m_nWordWrap = -1; 54 | m_bFormatBar = FALSE; 55 | m_bRulerBar = FALSE; 56 | m_bStatusBar = FALSE; 57 | m_bToolBar = FALSE; 58 | } 59 | 60 | CDocOptPage::~CDocOptPage() 61 | { 62 | } 63 | 64 | void CDocOptPage::DoDataExchange(CDataExchange* pDX) 65 | { 66 | CCSPropertyPage::DoDataExchange(pDX); 67 | //{{AFX_DATA_MAP(CDocOptPage) 68 | DDX_Radio(pDX, IDC_WRAP_NONE, m_nWordWrap); 69 | DDX_Check(pDX, IDC_CHECK_FORMATBAR, m_bFormatBar); 70 | DDX_Check(pDX, IDC_CHECK_RULERBAR, m_bRulerBar); 71 | DDX_Check(pDX, IDC_CHECK_STATUSBAR, m_bStatusBar); 72 | DDX_Check(pDX, IDC_CHECK_TOOLBAR, m_bToolBar); 73 | //}}AFX_DATA_MAP 74 | } 75 | 76 | 77 | BEGIN_MESSAGE_MAP(CDocOptPage, CCSPropertyPage) 78 | //{{AFX_MSG_MAP(CDocOptPage) 79 | // NOTE: the ClassWizard will add message map macros here 80 | //}}AFX_MSG_MAP 81 | END_MESSAGE_MAP() 82 | 83 | 84 | ///////////////////////////////////////////////////////////////////////////// 85 | // CDocOptPage message handlers 86 | 87 | ///////////////////////////////////////////////////////////////////////////// 88 | // CEmbeddedOptPage property page 89 | 90 | CEmbeddedOptPage::CEmbeddedOptPage() : CDocOptPage(IDS_EMBEDDED_OPTIONS) 91 | { 92 | } 93 | 94 | BOOL CEmbeddedOptPage::OnInitDialog() 95 | { 96 | BOOL b = CDocOptPage::OnInitDialog(); 97 | GetDlgItem(IDC_CHECK_STATUSBAR)->ShowWindow(SW_HIDE); 98 | return b; 99 | } 100 | -------------------------------------------------------------------------------- /docopt.h: -------------------------------------------------------------------------------- 1 | // docopt.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CDocOptPage dialog 14 | 15 | class CDocOptPage : public CCSPropertyPage 16 | { 17 | // Construction 18 | public: 19 | CDocOptPage(); 20 | CDocOptPage(UINT nIDCaption); 21 | ~CDocOptPage(); 22 | 23 | // Dialog Data 24 | //{{AFX_DATA(CDocOptPage) 25 | enum { IDD = IDD_OPTIONS_WRAP }; 26 | int m_nWordWrap; 27 | BOOL m_bFormatBar; 28 | BOOL m_bRulerBar; 29 | BOOL m_bStatusBar; 30 | BOOL m_bToolBar; 31 | //}}AFX_DATA 32 | 33 | 34 | // Overrides 35 | static const DWORD m_nHelpIDs[]; 36 | virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} 37 | // ClassWizard generate virtual function overrides 38 | //{{AFX_VIRTUAL(CDocOptPage) 39 | protected: 40 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 41 | //}}AFX_VIRTUAL 42 | 43 | // Implementation 44 | protected: 45 | // Generated message map functions 46 | //{{AFX_MSG(CDocOptPage) 47 | // NOTE: the ClassWizard will add member functions here 48 | //}}AFX_MSG 49 | DECLARE_MESSAGE_MAP() 50 | 51 | }; 52 | 53 | class CEmbeddedOptPage : public CDocOptPage 54 | { 55 | // Construction 56 | public: 57 | CEmbeddedOptPage(); 58 | // Overrides 59 | BOOL OnInitDialog(); 60 | }; 61 | -------------------------------------------------------------------------------- /doctype.cpp: -------------------------------------------------------------------------------- 1 | // richdoc.cpp : implementation of the CRichEditDoc class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "resource.h" 14 | #include "strings.h" 15 | 16 | #include "multconv.h" 17 | 18 | #ifdef _DEBUG 19 | #undef THIS_FILE 20 | static char BASED_CODE THIS_FILE[] = __FILE__; 21 | #endif 22 | 23 | static const BYTE byteRTFPrefix[5] = {'{', '\\', 'r', 't', 'f'}; 24 | static const BYTE byteWord2Prefix[4] = {0xDB, 0xA5, 0x2D, 0x00}; 25 | static const BYTE byteCompFilePrefix[8] = {0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1}; 26 | static const BYTE byteWrite1Prefix[2] = {0x31, 0xBE}; 27 | static const BYTE byteWrite2Prefix[2] = {0x32, 0xBE}; 28 | static const BYTE byteExePrefix[2] = {0x4D, 0x5A}; 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | 32 | static BOOL IsConverterFormat(LPCTSTR pszConverter, LPCTSTR pszPathName); 33 | static BOOL IsWord6(LPCTSTR pszConverter, LPCTSTR pszPathName); 34 | 35 | DocType doctypes[NUM_DOC_TYPES] = 36 | { 37 | DECLARE_DOCTYPE(WINWORD2, FALSE, FALSE, FALSE, NULL), 38 | DECLARE_DOCTYPE(WINWORD6, TRUE, FALSE, TRUE, szWordConverter), 39 | DECLARE_DOCTYPE_SYN(WORDPAD, WINWORD6, TRUE, TRUE, FALSE, szWordConverter), 40 | DECLARE_DOCTYPE(WRITE, TRUE, FALSE, FALSE, szWriteConverter), 41 | DECLARE_DOCTYPE(RICHTEXT, TRUE, TRUE, FALSE, NULL), 42 | DECLARE_DOCTYPE(TEXT, TRUE, TRUE, FALSE, NULL), 43 | DECLARE_DOCTYPE(OEMTEXT, TRUE, TRUE, FALSE, NULL), 44 | DECLARE_DOCTYPE(ALL, TRUE, FALSE, FALSE, NULL), 45 | DECLARE_DOCTYPE(EXE, FALSE, FALSE, FALSE, NULL), 46 | DECLARE_DOCTYPE_NULL(EMBEDDED, FALSE, FALSE, FALSE, NULL) 47 | }; 48 | 49 | CString DocType::GetString(int nIndex) 50 | { 51 | ASSERT(idStr != NULL); 52 | CString str; 53 | VERIFY(str.LoadString(idStr)); 54 | CString strSub; 55 | AfxExtractSubString(strSub, str, nIndex); 56 | nID = nIndex; 57 | return strSub; 58 | } 59 | 60 | static BOOL IsConverterFormat(LPCSTR pszConverter, LPCTSTR pszPathName) 61 | { 62 | CConverter conv(pszConverter); 63 | return conv.IsFormatCorrect(pszPathName); 64 | } 65 | 66 | static BOOL IsLeadMatch(CFile& file, const BYTE* pb, UINT nCount) 67 | { 68 | // check for match at beginning of file 69 | BOOL b = FALSE; 70 | BYTE* buf = new BYTE[nCount]; 71 | 72 | TRY 73 | { 74 | file.SeekToBegin(); 75 | memset(buf, 0, nCount); 76 | file.Read(buf, nCount); 77 | if (memcmp(buf, pb, nCount) == 0) 78 | b = TRUE; 79 | } 80 | END_TRY 81 | 82 | delete [] buf; 83 | return b; 84 | } 85 | 86 | static BOOL IsWord6(LPCTSTR pszPathName) 87 | { 88 | USES_CONVERSION; 89 | BOOL bRes = FALSE; 90 | // see who created it 91 | LPSTORAGE lpStorage; 92 | SCODE sc = StgOpenStorage(CT2COLE(pszPathName), NULL, 93 | STGM_READ|STGM_SHARE_EXCLUSIVE, 0, 0, &lpStorage); 94 | if (sc == NOERROR) 95 | { 96 | LPSTREAM lpStream; 97 | sc = lpStorage->OpenStream(CT2COLE(szSumInfo), NULL, 98 | STGM_READ|STGM_SHARE_EXCLUSIVE, NULL, &lpStream); 99 | if (sc == NOERROR) 100 | { 101 | lpStream->Release(); 102 | bRes = TRUE; 103 | } 104 | lpStorage->Release(); 105 | } 106 | return bRes; 107 | } 108 | 109 | int GetDocTypeFromName(LPCTSTR pszPathName, CFileException& fe) 110 | { 111 | CFile file; 112 | ASSERT(pszPathName != NULL); 113 | 114 | if (!file.Open(pszPathName, CFile::modeRead | CFile::shareDenyWrite, &fe)) 115 | return -1; 116 | 117 | CFileStatus stat; 118 | VERIFY(file.GetStatus(stat)); 119 | 120 | if (stat.m_size == 0) // file is empty 121 | { 122 | CString ext = CString(pszPathName).Right(4); 123 | if (ext[0] != '.') 124 | return RD_TEXT; 125 | #pragma warning(suppress:6400) 126 | if (lstrcmpi(ext, _T(".doc"))==0) 127 | return RD_WORDPAD; 128 | #pragma warning(suppress:6400) 129 | if (lstrcmpi(ext, _T(".rtf"))==0) 130 | return RD_RICHTEXT; 131 | return RD_TEXT; 132 | } 133 | // RTF 134 | if (IsLeadMatch(file, byteRTFPrefix, sizeof(byteRTFPrefix))) 135 | return RD_RICHTEXT; 136 | // WORD 2 137 | if (IsLeadMatch(file, byteWord2Prefix, sizeof(byteWord2Prefix))) 138 | return RD_WINWORD2; 139 | // EXE 140 | if (IsLeadMatch(file, byteExePrefix, sizeof(byteExePrefix))) 141 | return RD_EXE; 142 | // write file can start with 31BE or 32BE depending on whether it has 143 | // OLE objects in it or not 144 | if (IsLeadMatch(file, byteWrite1Prefix, sizeof(byteWrite1Prefix)) || 145 | IsLeadMatch(file, byteWrite2Prefix, sizeof(byteWrite2Prefix))) 146 | { 147 | file.Close(); 148 | if (IsConverterFormat(szWriteConverter, pszPathName)) 149 | return RD_WRITE; 150 | else 151 | return RD_TEXT; 152 | } 153 | 154 | // test for compound file 155 | if (IsLeadMatch(file, byteCompFilePrefix, sizeof(byteCompFilePrefix))) 156 | { 157 | file.Close(); 158 | if (IsConverterFormat(szWordConverter, pszPathName)) 159 | { 160 | if (IsWord6(pszPathName)) 161 | return RD_WINWORD6; 162 | else 163 | return RD_WORDPAD; 164 | } 165 | return RD_TEXT; 166 | } 167 | return RD_TEXT; 168 | } 169 | 170 | void ScanForConverters() 171 | { 172 | static BOOL bScanned = FALSE; 173 | if (bScanned) 174 | return; 175 | 176 | for (int i=0;im_bSaveAndValidate) 83 | { 84 | GetDlgItemText(IDC_EDIT_BEFORE, strBefore); 85 | m_nBefore = _ttoi(strBefore); 86 | 87 | GetDlgItemText(IDC_EDIT_AFTER, strAfter); 88 | m_nAfter = _ttoi(strAfter); 89 | } 90 | 91 | strBefore = FormatAsPoints(m_nBefore); 92 | strAfter = FormatAsPoints(m_nAfter); 93 | 94 | DDX_Text(pDX, IDC_EDIT_AFTER, strAfter); 95 | DDX_Text(pDX, IDC_EDIT_BEFORE, strBefore); 96 | 97 | //{{AFX_DATA_MAP(CFormatParaDlg) 98 | DDX_CBIndex(pDX, IDC_COMBO_ALIGNMENT, m_nAlignment); 99 | DDX_Twips(pDX, IDC_EDIT_FIRST_LINE, m_nFirst); 100 | DDV_MinMaxTwips(pDX, m_nFirst, -31680, 31680); 101 | DDX_Twips(pDX, IDC_EDIT_LEFT, m_nLeft); 102 | DDV_MinMaxTwips(pDX, m_nLeft, -31680, 31680); 103 | DDX_Twips(pDX, IDC_EDIT_RIGHT, m_nRight); 104 | DDV_MinMaxTwips(pDX, m_nRight, -31680, 31680); 105 | DDX_Check(pDX, IDC_CHECK_PAGEBREAK, m_bPageBreak); 106 | //}}AFX_DATA_MAP 107 | } 108 | 109 | BEGIN_MESSAGE_MAP(CFormatParaDlg, CCSDialog) 110 | //{{AFX_MSG_MAP(CFormatParaDlg) 111 | ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BEFORE, OnDeltaposSpinBefore) 112 | ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_AFTER, OnDeltaposSpinAfter) 113 | //}}AFX_MSG_MAP 114 | END_MESSAGE_MAP() 115 | 116 | 117 | ///////////////////////////////////////////////////////////////////////////// 118 | // CFormatParaDlg message handlers 119 | 120 | void CFormatParaDlg::OnOK() 121 | { 122 | CCSDialog::OnOK(); 123 | m_pf.dwMask = 0; 124 | if (m_nAlignment >= 0) 125 | { 126 | ASSERT(m_nAlignment < 3); 127 | m_pf.dwMask |= PFM_ALIGNMENT; 128 | m_pf.wAlignment = (WORD)((m_nAlignment == 0) ? PFA_LEFT : 129 | (m_nAlignment == 1) ? PFA_RIGHT : PFA_CENTER); 130 | } 131 | if (m_nRight != DDXM_BLANK) 132 | m_pf.dwMask |= PFM_RIGHTINDENT; 133 | if (m_nLeft != DDXM_BLANK && m_nFirst != DDXM_BLANK) 134 | m_pf.dwMask |= PFM_STARTINDENT; 135 | if (m_nFirst != DDXM_BLANK) 136 | m_pf.dwMask |= PFM_OFFSET; 137 | 138 | if (m_bPageBreak) 139 | { 140 | m_pf.dwMask |= PFM_PAGEBREAKBEFORE; 141 | m_pf.wEffects |= PFE_PAGEBREAKBEFORE; 142 | } 143 | 144 | m_pf.dxRightIndent = m_nRight; 145 | m_pf.dxOffset = -m_nFirst; 146 | m_pf.dxStartIndent = m_nLeft + m_nFirst; 147 | 148 | m_pf.dwMask |= PFM_SPACEAFTER | PFM_SPACEBEFORE; 149 | m_pf.dySpaceBefore = m_nBefore * 20; 150 | m_pf.dySpaceAfter = m_nAfter * 20; 151 | } 152 | 153 | BOOL CFormatParaDlg::OnInitDialog() 154 | { 155 | CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_COMBO_ALIGNMENT); 156 | CString str; 157 | str.LoadString(IDS_LEFT); 158 | pBox->AddString(str); 159 | str.LoadString(IDS_RIGHT); 160 | pBox->AddString(str); 161 | str.LoadString(IDS_CENTER); 162 | pBox->AddString(str); 163 | 164 | if (m_nWordWrap == 0) 165 | { 166 | GetDlgItem(IDC_COMBO_ALIGNMENT)->EnableWindow(FALSE); 167 | GetDlgItem(IDC_TEXT_ALIGNMENT)->EnableWindow(FALSE); 168 | } 169 | 170 | m_bPageBreak = (m_pf.dwMask & PFM_PAGEBREAKBEFORE) && 171 | (m_pf.wEffects & PFE_PAGEBREAKBEFORE); 172 | 173 | m_nRight = (m_pf.dwMask & PFM_RIGHTINDENT) ? m_pf.dxRightIndent : DDXM_BLANK; 174 | if (m_pf.dwMask & PFM_OFFSET) 175 | { 176 | m_nFirst = -m_pf.dxOffset; 177 | m_nLeft = (m_pf.dwMask & PFM_STARTINDENT) ? 178 | m_pf.dxStartIndent + m_pf.dxOffset : DDXM_BLANK; 179 | } 180 | else 181 | m_nLeft = m_nFirst = DDXM_BLANK; 182 | 183 | if (m_pf.dwMask & PFM_SPACEBEFORE) 184 | m_nBefore = m_pf.dySpaceBefore / 20; 185 | if (m_pf.dwMask & PFM_SPACEAFTER) 186 | m_nAfter = m_pf.dySpaceAfter / 20; 187 | 188 | CCSDialog::OnInitDialog(); 189 | return TRUE; // return TRUE unless you set the focus to a control 190 | // EXCEPTION: OCX Property Pages should return FALSE 191 | } 192 | 193 | void CFormatParaDlg::OnDeltaposSpinBefore(NMHDR* pNMHDR, LRESULT* pResult) 194 | { 195 | NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 196 | m_nBefore = pNMUpDown->iPos; 197 | *pResult = 0; 198 | UpdateData(FALSE); 199 | } 200 | 201 | void CFormatParaDlg::OnDeltaposSpinAfter(NMHDR* pNMHDR, LRESULT* pResult) 202 | { 203 | NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 204 | m_nAfter = pNMUpDown->iPos; 205 | *pResult = 0; 206 | UpdateData(FALSE); 207 | } 208 | 209 | -------------------------------------------------------------------------------- /formatpa.h: -------------------------------------------------------------------------------- 1 | // formatpa.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CFormatParaDlg dialog 14 | 15 | class CFormatParaDlg : public CCSDialog 16 | { 17 | // Construction 18 | public: 19 | CFormatParaDlg(PARAFORMAT2& pf, CWnd* pParent = NULL); // standard constructor 20 | PARAFORMAT2 m_pf; 21 | 22 | // Attributes 23 | int m_nWordWrap; 24 | 25 | // Dialog Data 26 | //{{AFX_DATA(CFormatParaDlg) 27 | enum { IDD = IDD_FORMAT_PARA }; 28 | int m_nAlignment; 29 | int m_nFirst; 30 | int m_nLeft; 31 | int m_nRight; 32 | BOOL m_bPageBreak; 33 | int m_nAfter; 34 | int m_nBefore; 35 | //}}AFX_DATA 36 | 37 | // Implementation 38 | protected: 39 | static const DWORD m_nHelpIDs[]; 40 | virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} 41 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 42 | virtual void OnOK(); 43 | 44 | // Generated message map functions 45 | //{{AFX_MSG(CFormatParaDlg) 46 | virtual BOOL OnInitDialog(); 47 | afx_msg void OnDeltaposSpinBefore(NMHDR* pNMHDR, LRESULT* pResult); 48 | afx_msg void OnDeltaposSpinAfter(NMHDR* pNMHDR, LRESULT* pResult); 49 | //}}AFX_MSG 50 | DECLARE_MESSAGE_MAP() 51 | }; 52 | -------------------------------------------------------------------------------- /formatta.cpp: -------------------------------------------------------------------------------- 1 | // formatta.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "formatta.h" 15 | #include "ddxm.h" 16 | #include "helpids.h" 17 | 18 | #ifdef _DEBUG 19 | #undef THIS_FILE 20 | static char BASED_CODE THIS_FILE[] = __FILE__; 21 | #endif 22 | 23 | const DWORD CFormatTabDlg::m_nHelpIDs[] = 24 | { 25 | IDC_BUTTON_SET, IDH_WORDPAD_TABSET, 26 | IDC_BUTTON_CLEAR, IDH_WORDPAD_TABCLEAR, 27 | IDC_BUTTON_CLEARALL, IDH_WORDPAD_TAB_CLEARALL, 28 | IDC_COMBO1, IDH_WORDPAD_TABSTOPS, 29 | IDC_BOX, IDH_COMM_GROUPBOX, 30 | 0, 0 31 | }; 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | // CFormatTabDlg dialog 35 | 36 | CFormatTabDlg::CFormatTabDlg(PARAFORMAT2& pf, CWnd* pParent /*=NULL*/) 37 | : CCSDialog(CFormatTabDlg::IDD, pParent) 38 | { 39 | m_pf = pf; 40 | m_tabarray = new LONG[MAX_TAB_STOPS]; 41 | m_nCount = 0; 42 | if (m_pf.dwMask & PFM_TABSTOPS) 43 | { 44 | m_nCount = m_pf.cTabCount; 45 | ASSERT(m_pf.cTabCount <= MAX_TAB_STOPS); 46 | for (int i=0;im_bSaveAndValidate) 69 | UpdateListBox(); 70 | } 71 | 72 | BEGIN_MESSAGE_MAP(CFormatTabDlg, CCSDialog) 73 | //{{AFX_MSG_MAP(CFormatTabDlg) 74 | ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnClickedClear) 75 | ON_BN_CLICKED(IDC_BUTTON_CLEARALL, OnClickedClearAll) 76 | ON_BN_CLICKED(IDC_BUTTON_SET, OnClickedSet) 77 | ON_CBN_EDITCHANGE(IDC_COMBO1, OnEditChange) 78 | ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchange) 79 | //}}AFX_MSG_MAP 80 | END_MESSAGE_MAP() 81 | 82 | 83 | ///////////////////////////////////////////////////////////////////////////// 84 | // CFormatTabDlg message handlers 85 | 86 | void CFormatTabDlg::OnClickedClear() 87 | { 88 | int nTab; 89 | int nSel = m_comboBox.GetCurSel(); 90 | if (nSel == CB_ERR) 91 | { 92 | CDataExchange dx(this, TRUE); 93 | DDX_Twips(&dx, IDC_COMBO1, nTab); 94 | DDV_MinMaxTwips(&dx, nTab, 0, 31680); 95 | if (nTab != DDXM_BLANK) 96 | { 97 | if (RemoveTabFromArray(nTab)) 98 | UpdateListBox(); 99 | } 100 | } 101 | else 102 | { 103 | ASSERT(nSel < m_nCount); 104 | RemoveTabFromArrayByIndex(nSel); 105 | UpdateListBox(); 106 | } 107 | UpdateButtons(); 108 | SetEditFocus(); 109 | } 110 | 111 | void CFormatTabDlg::OnClickedClearAll() 112 | { 113 | m_nCount = 0; 114 | m_comboBox.ResetContent(); 115 | UpdateButtons(); 116 | SetEditFocus(); 117 | } 118 | 119 | void CFormatTabDlg::OnClickedSet() 120 | { 121 | Set(); 122 | UpdateButtons(); 123 | SetEditFocus(); 124 | } 125 | 126 | BOOL CFormatTabDlg::Set() 127 | { 128 | int nTab; 129 | CDataExchange dx(this, TRUE); 130 | DDX_Twips(&dx, IDC_COMBO1, nTab); 131 | DDV_MinMaxTwips(&dx, nTab, 0, 31680); 132 | if (nTab != DDXM_BLANK) 133 | { 134 | if (m_nCount == MAX_TAB_STOPS) 135 | { 136 | AfxMessageBox(IDS_NOMORETABS); 137 | m_comboBox.Clear(); 138 | return FALSE; 139 | } 140 | if (AddTabToArray(nTab)) 141 | UpdateListBox(); 142 | return TRUE; 143 | } 144 | return FALSE; 145 | } 146 | 147 | void CFormatTabDlg::SetEditFocus() 148 | { 149 | m_comboBox.SetFocus(); 150 | m_comboBox.SetEditSel(0,-1); 151 | } 152 | 153 | BOOL CFormatTabDlg::RemoveTabFromArray(LONG lTab) 154 | { 155 | int i; 156 | for (i=0;i= 0); 201 | m_comboBox.ResetContent(); 202 | for (i=0;i 0); 237 | BOOL bHasText = (m_comboBox.GetWindowTextLength() > 0); 238 | UpdateButton(m_buttonSet, bHasText); 239 | UpdateButton(m_buttonClear, bHasText); 240 | WORD wID = LOWORD(GetDefID()); 241 | if (bHasText && wID != IDC_BUTTON_SET) 242 | SetDefID(IDC_BUTTON_SET); 243 | else if (!bHasText && wID != IDOK) 244 | SetDefID(IDOK); 245 | } 246 | 247 | BOOL CFormatTabDlg::OnInitDialog() 248 | { 249 | CCSDialog::OnInitDialog(); 250 | UpdateButtons(); 251 | return TRUE; // return TRUE unless you set the focus to a control 252 | // EXCEPTION: OCX Property Pages should return FALSE 253 | } 254 | 255 | void CFormatTabDlg::OnSelchange() 256 | { 257 | UpdateButton(m_buttonClearAll, m_nCount > 0); 258 | // force these since if the edit control is empty and 259 | // an item in the box is clicked on, the edit control will 260 | // not be filled in first 261 | UpdateButton(m_buttonSet, TRUE); 262 | UpdateButton(m_buttonClear, TRUE); 263 | WORD wID = LOWORD(GetDefID()); 264 | if (wID != IDC_BUTTON_SET) 265 | SetDefID(IDC_BUTTON_SET); 266 | } 267 | -------------------------------------------------------------------------------- /formatta.h: -------------------------------------------------------------------------------- 1 | // formatta.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CFormatTabDlg dialog 14 | 15 | class CFormatTabDlg : public CCSDialog 16 | { 17 | // Construction 18 | public: 19 | CFormatTabDlg(PARAFORMAT2& pf, CWnd* pParent = NULL); // standard constructor 20 | ~CFormatTabDlg(); 21 | PARAFORMAT2 m_pf; 22 | LONG* m_tabarray; 23 | int m_nCount; 24 | 25 | // Dialog Data 26 | //{{AFX_DATA(CFormatTabDlg) 27 | enum { IDD = IDD_FORMAT_TAB }; 28 | CButton m_buttonClearAll; 29 | CButton m_buttonSet; 30 | CButton m_buttonClear; 31 | CComboBox m_comboBox; 32 | //}}AFX_DATA 33 | 34 | // Implementation 35 | protected: 36 | static const DWORD m_nHelpIDs[]; 37 | virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} 38 | void UpdateButton(CButton& button, BOOL b); 39 | void UpdateButtons(); 40 | BOOL Set(); 41 | BOOL AddTabToArray(LONG lTab); 42 | BOOL RemoveTabFromArray(LONG lTab); 43 | void RemoveTabFromArrayByIndex(int nIndex); 44 | void UpdateListBox(); 45 | void SetEditFocus(); 46 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 47 | virtual void OnOK(); 48 | 49 | // Generated message map functions 50 | //{{AFX_MSG(CFormatTabDlg) 51 | afx_msg void OnClickedClear(); 52 | afx_msg void OnClickedClearAll(); 53 | afx_msg void OnClickedSet(); 54 | afx_msg void OnEditChange(); 55 | virtual BOOL OnInitDialog(); 56 | afx_msg void OnSelchange(); 57 | //}}AFX_MSG 58 | DECLARE_MESSAGE_MAP() 59 | }; 60 | -------------------------------------------------------------------------------- /helpids.h: -------------------------------------------------------------------------------- 1 | // This is a part of the Microsoft Foundation Classes C++ library. 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // This source code is only intended as a supplement to the 5 | // Microsoft Foundation Classes Reference and related 6 | // electronic documentation provided with the library. 7 | // See these sources for detailed information regarding the 8 | // Microsoft Foundation Classes product. 9 | 10 | #define IDH_WORDPAD_TIMEDATE 1001 11 | 12 | #define IDH_WORDPAD_ALIGN 1003 13 | #define IDH_WORDPAD_TABSET 1004 14 | #define IDH_WORDPAD_TABCLEAR 1005 15 | #define IDH_WORDPAD_TAB_CLEARALL 1006 16 | #define IDH_WORDPAD_TABSTOPS 1007 17 | #define IDH_WORDPAD_TEXTFILE 1008 18 | #define IDH_WORDPAD_FORMATTED 1009 19 | 20 | #define IDH_WORDPAD_WORD6FILE 1017 21 | #define IDH_WORDPAD_FILENEW_DOC 1018 22 | #define IDH_WORDPAD_OPTIONS_AUTOWORDSEL 1019 23 | 24 | #define IDH_WORDPAD_INDENT_LEFT 1020 25 | #define IDH_WORDPAD_INDENT_RIGHT 1021 26 | #define IDH_WORDPAD_INDENT_FIRST 1022 27 | 28 | #define IDH_WORDPAD_WRAP_NO 1023 29 | #define IDH_WORDPAD_WRAP_WINDOW 1024 30 | #define IDH_WORDPAD_WRAP_RULER 1025 31 | 32 | #define IDH_COMM_GROUPBOX 1026 33 | 34 | #define IDH_WORDPAD_INCHES 1027 35 | #define IDH_WORDPAD_CENTIMETERS 1028 36 | #define IDH_WORDPAD_POINTS 1029 37 | #define IDH_WORDPAD_PICAS 1030 38 | 39 | #define IDH_WORDPAD_CHECK_TOOLBAR 1031 40 | #define IDH_WORDPAD_CHECK_FORMATBAR 1032 41 | #define IDH_WORDPAD_CHECK_STATUSBAR 1033 42 | #define IDH_WORDPAD_CHECK_RULERBAR 1034 43 | 44 | #define IDH_WORDPAD_TOPMARGIN 1035 45 | #define IDH_WORDPAD_BOTTOMMARGIN 1036 46 | #define IDH_WORDPAD_LEFTMARGIN 1037 47 | #define IDH_WORDPAD_RIGHTMARGIN 1038 48 | 49 | #define IDH_WORDPAD_SPACE_BEFORE 1039 50 | #define IDH_WORDPAD_SPACE_AFTER 1040 51 | #define IDH_WORDPAD_PAGEBREAK 1041 52 | 53 | -------------------------------------------------------------------------------- /ipframe.cpp: -------------------------------------------------------------------------------- 1 | // ipframe.cpp : implementation of the CInPlaceFrame class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "formatba.h" 15 | #include "ruler.h" 16 | #include "ipframe.h" 17 | #include "wordpdoc.h" 18 | #include "wordpvw.h" 19 | #include "colorlis.h" 20 | 21 | #ifdef _DEBUG 22 | #undef THIS_FILE 23 | static char BASED_CODE THIS_FILE[] = __FILE__; 24 | #endif 25 | 26 | ///////////////////////////////////////////////////////////////////////////// 27 | // CInPlaceFrame 28 | 29 | IMPLEMENT_DYNCREATE(CInPlaceFrame, COleIPFrameWnd) 30 | 31 | BEGIN_MESSAGE_MAP(CInPlaceFrame, COleIPFrameWnd) 32 | //{{AFX_MSG_MAP(CInPlaceFrame) 33 | ON_WM_CREATE() 34 | ON_WM_DESTROY() 35 | ON_COMMAND(ID_HELP, OnHelpFinder) 36 | ON_COMMAND(ID_CHAR_COLOR, OnCharColor) 37 | ON_COMMAND(ID_HELP_INDEX, OnHelpFinder) 38 | ON_COMMAND(ID_PEN_TOGGLE, OnPenToggle) 39 | //}}AFX_MSG_MAP 40 | ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR, OnUpdateControlBarMenu) 41 | ON_COMMAND_EX(ID_VIEW_TOOLBAR, OnBarCheck) 42 | ON_UPDATE_COMMAND_UI(ID_VIEW_FORMATBAR, OnUpdateControlBarMenu) 43 | ON_COMMAND_EX(ID_VIEW_FORMATBAR, OnBarCheck) 44 | ON_UPDATE_COMMAND_UI(ID_VIEW_RULER, OnUpdateControlBarMenu) 45 | ON_COMMAND_EX(ID_VIEW_RULER, OnBarCheck) 46 | ON_MESSAGE(WM_SIZECHILD, OnResizeChild) 47 | ON_MESSAGE(WPM_BARSTATE, OnBarState) 48 | ON_COMMAND(ID_DEFAULT_HELP, OnHelpFinder) 49 | // ON_COMMAND(ID_CONTEXT_HELP, COleIPFrameWnd::OnContextHelp) 50 | END_MESSAGE_MAP() 51 | 52 | ///////////////////////////////////////////////////////////////////////////// 53 | // arrays of IDs used to initialize control bars 54 | 55 | static UINT BASED_CODE toolButtons[] = 56 | { 57 | // same order as in the bitmap 'itoolbar.bmp' 58 | ID_EDIT_CUT, 59 | ID_EDIT_COPY, 60 | ID_EDIT_PASTE, 61 | 62 | ID_SEPARATOR, 63 | ID_PEN_TOGGLE, 64 | ID_PEN_PERIOD, 65 | ID_PEN_SPACE, 66 | ID_PEN_BACKSPACE, 67 | ID_PEN_NEWLINE, 68 | ID_PEN_LENS 69 | }; 70 | 71 | #define NUM_PEN_ITEMS 7 72 | #define NUM_PEN_TOGGLE 5 73 | 74 | static UINT BASED_CODE format[] = 75 | { 76 | // same order as in the bitmap 'format.bmp' 77 | ID_SEPARATOR, // font name combo box 78 | ID_SEPARATOR, 79 | ID_SEPARATOR, // font size combo box 80 | ID_SEPARATOR, 81 | ID_CHAR_BOLD, 82 | ID_CHAR_ITALIC, 83 | ID_CHAR_UNDERLINE, 84 | ID_CHAR_COLOR, 85 | ID_SEPARATOR, 86 | ID_PARA_LEFT, 87 | ID_PARA_CENTER, 88 | ID_PARA_RIGHT, 89 | ID_SEPARATOR, 90 | ID_INSERT_BULLET, 91 | }; 92 | 93 | ///////////////////////////////////////////////////////////////////////////// 94 | // CInPlaceFrame construction/destruction 95 | 96 | CInPlaceFrame::CInPlaceFrame() : m_wndRulerBar(FALSE) 97 | { 98 | } 99 | 100 | int CInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 101 | { 102 | if (COleIPFrameWnd::OnCreate(lpCreateStruct) == -1) 103 | return -1; 104 | 105 | // CResizeBar implements in-place resizing. 106 | if (!m_wndResizeBar.Create(this)) 107 | { 108 | TRACE0("Failed to create resize bar\n"); 109 | return -1; // fail to create 110 | } 111 | 112 | if (!CreateRulerBar(this)) 113 | return FALSE; 114 | 115 | // By default, it is a good idea to register a drop-target that does 116 | // nothing with your frame window. This prevents drops from 117 | // "falling through" to a container that supports drag-drop. 118 | m_dropTarget.Register(this); 119 | 120 | return 0; 121 | } 122 | 123 | // OnCreateControlBars is called by the framework to create control bars on the 124 | // container application's windows. pWndFrame is the top level frame window of 125 | // the container and is always non-NULL. pWndDoc is the doc level frame window 126 | // and will be NULL when the container is an SDI application. A server 127 | // application can place MFC control bars on either window. 128 | BOOL CInPlaceFrame::OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* /*pWndDoc*/) 129 | { 130 | if (!CreateToolBar(pWndFrame)) 131 | return FALSE; 132 | 133 | if (!CreateFormatBar(pWndFrame)) 134 | return FALSE; 135 | 136 | // set owner to this window, so messages are delivered to correct app 137 | m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 138 | m_wndFormatBar.EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM); 139 | pWndFrame->EnableDocking(CBRS_ALIGN_ANY); 140 | pWndFrame->DockControlBar(&m_wndToolBar); 141 | pWndFrame->DockControlBar(&m_wndFormatBar); 142 | 143 | m_wndToolBar.SetOwner(this); 144 | m_wndFormatBar.SetOwner(this); 145 | m_wndRulerBar.SetOwner(this); 146 | OnBarState(1, RD_EMBEDDED); //load bar state 147 | return TRUE; 148 | } 149 | 150 | BOOL CInPlaceFrame::CreateToolBar(CWnd* pWndFrame) 151 | { 152 | // Create toolbar on client's frame window 153 | ASSERT(m_wndToolBar.m_hWnd == NULL); 154 | int nPen = GetSystemMetrics(SM_PENWINDOWS) ? NUM_PEN_TOGGLE : 155 | NUM_PEN_ITEMS; 156 | UINT nID = theApp.m_bLargeIcons ? 157 | IDR_SRVR_INPLACE_BIG : IDR_SRVR_INPLACE; 158 | if (!m_wndToolBar.Create(pWndFrame, WS_CHILD|WS_VISIBLE|CBRS_TOP| 159 | CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)|| 160 | !m_wndToolBar.LoadBitmap(nID) || 161 | !m_wndToolBar.SetButtons(toolButtons, 162 | sizeof(toolButtons)/sizeof(UINT) - nPen)) 163 | { 164 | TRACE0("Failed to create toolbar\n"); 165 | return FALSE; // fail to create 166 | } 167 | if (theApp.m_bLargeIcons) 168 | m_wndToolBar.SetSizes(CSize(31,30), CSize(24,24)); 169 | else 170 | m_wndToolBar.SetSizes(CSize(23,22), CSize(16,16)); 171 | CString str; 172 | str.LoadString(IDS_TITLE_TOOLBAR); 173 | m_wndToolBar.SetWindowText(str); 174 | return TRUE; 175 | } 176 | 177 | BOOL CInPlaceFrame::CreateFormatBar(CWnd* pWndFrame) 178 | { 179 | ASSERT(m_wndFormatBar.m_hWnd == NULL); 180 | m_wndFormatBar.m_hWndOwner = m_hWnd; 181 | UINT nID = theApp.m_bLargeIcons ? IDB_FORMATBAR_BIG : IDB_FORMATBAR; 182 | if (!m_wndFormatBar.Create(pWndFrame, WS_CHILD|WS_VISIBLE|CBRS_TOP| 183 | CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC, ID_VIEW_FORMATBAR) || 184 | !m_wndFormatBar.LoadBitmap(nID) || 185 | !m_wndFormatBar.SetButtons(format, 186 | sizeof(format)/sizeof(UINT))) 187 | { 188 | TRACE0("Failed to create FormatBar\n"); 189 | return FALSE; // fail to create 190 | } 191 | 192 | if (theApp.m_bLargeIcons) 193 | m_wndFormatBar.SetSizes(CSize(31,30), CSize(24,24)); 194 | else 195 | m_wndFormatBar.SetSizes(CSize(23,22), CSize(16,16)); 196 | CString str; 197 | str.LoadString(IDS_TITLE_FORMATBAR); 198 | m_wndFormatBar.SetWindowText(str); 199 | m_wndFormatBar.PositionCombos(); 200 | return TRUE; 201 | } 202 | 203 | BOOL CInPlaceFrame::CreateRulerBar(CWnd* pWndFrame) 204 | { 205 | if (!m_wndRulerBar.Create(pWndFrame, 206 | WS_CHILD|WS_VISIBLE|CBRS_ALIGN_TOP|CBRS_HIDE_INPLACE, ID_VIEW_RULER)) 207 | { 208 | TRACE0("Failed to create ruler\n"); 209 | return FALSE; // fail to create 210 | } 211 | return TRUE; 212 | } 213 | 214 | ///////////////////////////////////////////////////////////////////////////// 215 | // CInPlaceFrame Operations 216 | 217 | ///////////////////////////////////////////////////////////////////////////// 218 | // CInPlaceFrame diagnostics 219 | 220 | #ifdef _DEBUG 221 | void CInPlaceFrame::AssertValid() const 222 | { 223 | COleIPFrameWnd::AssertValid(); 224 | } 225 | 226 | void CInPlaceFrame::Dump(CDumpContext& dc) const 227 | { 228 | COleIPFrameWnd::Dump(dc); 229 | } 230 | #endif //_DEBUG 231 | 232 | ///////////////////////////////////////////////////////////////////////////// 233 | // CInPlaceFrame commands 234 | 235 | void CInPlaceFrame::OnDestroy() 236 | { 237 | m_wndToolBar.DestroyWindow(); 238 | m_wndFormatBar.DestroyWindow(); 239 | COleIPFrameWnd::OnDestroy(); 240 | } 241 | 242 | void CInPlaceFrame::RepositionFrame(LPCRECT lpPosRect, LPCRECT lpClipRect) 243 | { 244 | CRect rectNew = lpPosRect; 245 | rectNew.left -= HORZ_TEXTOFFSET; 246 | rectNew.top -= VERT_TEXTOFFSET; 247 | m_wndResizeBar.BringWindowToTop(); 248 | COleIPFrameWnd::RepositionFrame(&rectNew, lpClipRect); 249 | CWnd* pWnd = GetActiveView(); 250 | if (pWnd != NULL) 251 | pWnd->BringWindowToTop(); 252 | m_wndRulerBar.BringWindowToTop(); 253 | } 254 | 255 | void CInPlaceFrame::RecalcLayout(BOOL bNotify) 256 | { 257 | if (m_wndResizeBar.m_hWnd != NULL) 258 | m_wndResizeBar.BringWindowToTop(); 259 | COleIPFrameWnd::RecalcLayout(bNotify); 260 | CWnd* pWnd = GetActiveView(); 261 | if (pWnd != NULL) 262 | pWnd->BringWindowToTop(); 263 | if (m_wndRulerBar.m_hWnd != NULL) 264 | m_wndRulerBar.BringWindowToTop(); 265 | 266 | // at least 12 pt region plus ruler if it exists 267 | CDisplayIC dc; 268 | CSize size; 269 | size.cy = MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72)+1; 270 | size.cx = dc.GetDeviceCaps(LOGPIXELSX)/4; // 1/4" 271 | size.cx += HORZ_TEXTOFFSET; //adjust for offset 272 | size.cy += VERT_TEXTOFFSET; 273 | if (m_wndRulerBar.m_hWnd != NULL && m_wndRulerBar.IsVisible()) 274 | { 275 | CRect rect; 276 | m_wndRulerBar.GetWindowRect(&rect); 277 | size.cy += rect.Height(); 278 | } 279 | m_wndResizeBar.SetMinSize(size); 280 | } 281 | 282 | void CInPlaceFrame::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType) 283 | { 284 | COleIPFrameWnd::CalcWindowRect(lpClientRect, nAdjustType); 285 | } 286 | 287 | LRESULT CInPlaceFrame::OnResizeChild(WPARAM /*wParam*/, LPARAM lParam) 288 | { 289 | // notify the container that the rectangle has changed! 290 | CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument(); 291 | if (pDoc == NULL) 292 | return 0; 293 | 294 | ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CWordPadDoc))); 295 | 296 | // get new rect and parent 297 | CRect rectNew; 298 | rectNew.CopyRect((LPCRECT)lParam); 299 | CWnd* pParentWnd = GetParent(); 300 | ASSERT_VALID(pParentWnd); 301 | 302 | // convert rectNew relative to pParentWnd 303 | ClientToScreen(&rectNew); 304 | pParentWnd->ScreenToClient(&rectNew); 305 | 306 | if (m_wndRulerBar.GetStyle()&WS_VISIBLE) 307 | { 308 | CRect rect; 309 | m_wndRulerBar.GetWindowRect(&rect); 310 | rectNew.top += rect.Height(); 311 | } 312 | rectNew.left += HORZ_TEXTOFFSET; 313 | rectNew.top += VERT_TEXTOFFSET; 314 | 315 | // adjust the new rectangle for the current control bars 316 | CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST); 317 | ENSURE(pLeftOver != NULL); 318 | CRect rectCur = m_rectPos; 319 | pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside); 320 | rectNew.left += m_rectPos.left - rectCur.left; 321 | rectNew.top += m_rectPos.top - rectCur.top; 322 | rectNew.right -= rectCur.right - m_rectPos.right; 323 | rectNew.bottom -= rectCur.bottom - m_rectPos.bottom; 324 | OnRequestPositionChange(rectNew); 325 | 326 | return 0; 327 | } 328 | 329 | LONG_PTR CInPlaceFrame::OnBarState(UINT_PTR wParam, LONG_PTR lParam) 330 | { 331 | if (lParam == -1) 332 | return 0L; 333 | if (wParam == 0) 334 | { 335 | GetDockState(theApp.GetDockState(RD_EMBEDDED)); 336 | ENSURE(m_pMainFrame != NULL); 337 | m_pMainFrame->GetDockState(theApp.GetDockState(RD_EMBEDDED, FALSE)); 338 | } 339 | else 340 | { 341 | SetDockState(theApp.GetDockState(RD_EMBEDDED)); 342 | m_pMainFrame->SetDockState(theApp.GetDockState(RD_EMBEDDED, FALSE)); 343 | } 344 | return 0L; 345 | } 346 | 347 | void CInPlaceFrame::OnHelpFinder() 348 | { 349 | theApp.WinHelp(0, HELP_FINDER); 350 | } 351 | 352 | void CInPlaceFrame::OnCharColor() 353 | { 354 | CColorMenu colorMenu; 355 | CRect rc; 356 | int index = m_wndFormatBar.CommandToIndex(ID_CHAR_COLOR); 357 | m_wndFormatBar.GetItemRect(index, &rc); 358 | m_wndFormatBar.ClientToScreen(rc); 359 | colorMenu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,rc.left,rc.bottom, this); 360 | } 361 | 362 | void CInPlaceFrame::OnPenToggle() 363 | { 364 | static int nPen = 0; 365 | m_wndToolBar.SetButtons(toolButtons, sizeof(toolButtons)/sizeof(UINT) - nPen); 366 | nPen = (nPen == 0) ? NUM_PEN_TOGGLE : 0; 367 | m_wndToolBar.Invalidate(); 368 | m_wndToolBar.GetParentFrame()->RecalcLayout(); 369 | } 370 | -------------------------------------------------------------------------------- /ipframe.h: -------------------------------------------------------------------------------- 1 | // ipframe.h : interface of the CInPlaceFrame class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | class CWordPadResizeBar : public COleResizeBar 13 | { 14 | public: 15 | void SetMinSize(CSize size) {m_tracker.m_sizeMin = size;} 16 | }; 17 | 18 | class CInPlaceFrame : public COleIPFrameWnd 19 | { 20 | private: 21 | using COleIPFrameWnd::OnCreateControlBars; 22 | 23 | DECLARE_DYNCREATE(CInPlaceFrame) 24 | public: 25 | CInPlaceFrame(); 26 | 27 | // Attributes 28 | public: 29 | CToolBar m_wndToolBar; 30 | CFormatBar m_wndFormatBar; 31 | CRulerBar m_wndRulerBar; 32 | CWordPadResizeBar m_wndResizeBar; 33 | COleDropTarget m_dropTarget; 34 | 35 | // Operations 36 | public: 37 | virtual void RecalcLayout(BOOL bNotify = TRUE); 38 | virtual void CalcWindowRect(LPRECT lpClientRect, 39 | UINT nAdjustType = adjustBorder); 40 | 41 | // Overrides 42 | // ClassWizard generated virtual function overrides 43 | //{{AFX_VIRTUAL(CInPlaceFrame) 44 | public: 45 | virtual BOOL OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* pWndDoc); 46 | virtual void RepositionFrame(LPCRECT lpPosRect, LPCRECT lpClipRect); 47 | //}}AFX_VIRTUAL 48 | 49 | // Implementation 50 | public: 51 | #ifdef _DEBUG 52 | virtual void AssertValid() const; 53 | virtual void Dump(CDumpContext& dc) const; 54 | #endif 55 | 56 | protected: 57 | BOOL CreateToolBar(CWnd* pWndFrame); 58 | BOOL CreateFormatBar(CWnd* pWndFrame); 59 | BOOL CreateRulerBar(CWnd* pWndFrame); 60 | 61 | // Generated message map functions 62 | protected: 63 | //{{AFX_MSG(CInPlaceFrame) 64 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 65 | afx_msg void OnDestroy(); 66 | afx_msg void OnHelpFinder(); 67 | afx_msg void OnCharColor(); 68 | afx_msg void OnPenToggle(); 69 | //}}AFX_MSG 70 | LRESULT OnResizeChild(WPARAM wParam, LPARAM lParam); 71 | afx_msg LONG_PTR OnBarState(UINT_PTR wParam, LONG_PTR lParam); 72 | DECLARE_MESSAGE_MAP() 73 | }; 74 | 75 | ///////////////////////////////////////////////////////////////////////////// 76 | -------------------------------------------------------------------------------- /key.cpp: -------------------------------------------------------------------------------- 1 | // key.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "key.h" 14 | #include 15 | 16 | #ifdef _DEBUG 17 | #undef THIS_FILE 18 | static char BASED_CODE THIS_FILE[] = __FILE__; 19 | #endif 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | // CKey 23 | 24 | void CKey::Close() 25 | { 26 | if (m_hKey != NULL) 27 | { 28 | LONG lRes = RegCloseKey(m_hKey); 29 | ASSERT(lRes == ERROR_SUCCESS); 30 | m_hKey = NULL; 31 | } 32 | } 33 | 34 | BOOL CKey::Create(HKEY hKey, LPCTSTR lpszKeyName) 35 | { 36 | ASSERT(hKey != NULL); 37 | return (RegCreateKey(hKey, lpszKeyName, &m_hKey) == ERROR_SUCCESS); 38 | } 39 | 40 | BOOL CKey::Open(HKEY hKey, LPCTSTR lpszKeyName) 41 | { 42 | ASSERT(hKey != NULL); 43 | return (RegOpenKey(hKey, lpszKeyName, &m_hKey) == ERROR_SUCCESS); 44 | } 45 | 46 | BOOL CKey::SetStringValue(LPCTSTR lpszValue, LPCTSTR lpszValueName) 47 | { 48 | ASSERT(m_hKey != NULL); 49 | return (RegSetValueEx(m_hKey, lpszValueName, NULL, REG_SZ, 50 | (BYTE * const)lpszValue, (lstrlen(lpszValue)+1)*sizeof(TCHAR)) == ERROR_SUCCESS); 51 | } 52 | 53 | BOOL CKey::GetStringValue(CString& str, LPCTSTR lpszValueName) 54 | { 55 | ASSERT(m_hKey != NULL); 56 | str.Empty(); 57 | DWORD dw = 0; 58 | DWORD dwType = 0; 59 | LONG lRes = RegQueryValueEx(m_hKey, (LPTSTR)lpszValueName, NULL, &dwType, 60 | NULL, &dw); 61 | if (lRes == ERROR_SUCCESS) 62 | { 63 | ASSERT(dwType == REG_SZ); 64 | LPTSTR lpsz = str.GetBufferSetLength(dw); 65 | lRes = RegQueryValueEx(m_hKey, (LPTSTR)lpszValueName, NULL, &dwType, (BYTE*)lpsz, &dw); 66 | ASSERT(lRes == ERROR_SUCCESS); 67 | str.ReleaseBuffer(); 68 | return TRUE; 69 | } 70 | return FALSE; 71 | } 72 | -------------------------------------------------------------------------------- /key.h: -------------------------------------------------------------------------------- 1 | // key.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CKey 14 | 15 | class CKey 16 | { 17 | public: 18 | CKey() {m_hKey = NULL;} 19 | ~CKey() {Close();} 20 | 21 | // Attributes 22 | public: 23 | HKEY m_hKey; 24 | BOOL SetStringValue(LPCTSTR lpszValue, LPCTSTR lpszValueName = NULL); 25 | BOOL GetStringValue(CString& str, LPCTSTR lpszValueName = NULL); 26 | 27 | // Operations 28 | public: 29 | BOOL Create(HKEY hKey, LPCTSTR lpszKeyName); 30 | BOOL Open(HKEY hKey, LPCTSTR lpszKeyName); 31 | void Close(); 32 | 33 | // Overrides 34 | 35 | // Implementation 36 | protected: 37 | }; 38 | 39 | ///////////////////////////////////////////////////////////////////////////// 40 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /listdlg.cpp: -------------------------------------------------------------------------------- 1 | // listdlg.cpp : Defines the class behaviors for the application. 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "resource.h" 14 | #include "listdlg.h" 15 | 16 | #ifdef _DEBUG 17 | #undef THIS_FILE 18 | static char BASED_CODE THIS_FILE[] = __FILE__; 19 | #endif 20 | 21 | BEGIN_MESSAGE_MAP(CListDlg, CDialog) 22 | //{{AFX_MSG_MAP(CListDlg) 23 | ON_LBN_DBLCLK(IDC_LISTDIALOG_LIST, OnOK) 24 | //}}AFX_MSG_MAP 25 | END_MESSAGE_MAP() 26 | 27 | CListDlg::CListDlg(UINT idStrDlgTitle, UINT idStrListTitle, 28 | const CStringList& listItems, int nDefSel) : CDialog(CListDlg::IDD), 29 | m_listItems(listItems) 30 | { 31 | VERIFY(m_strDlgTitle.LoadString(idStrDlgTitle)); 32 | VERIFY(m_strListTitle.LoadString(idStrListTitle)); 33 | m_nSelection = nDefSel; 34 | } 35 | 36 | BOOL CListDlg::OnInitDialog() 37 | { 38 | SetWindowText(m_strDlgTitle); 39 | // fix this 40 | SetDlgItemText(IDC_STATIC_HEADING, m_strListTitle); 41 | CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LISTDIALOG_LIST); 42 | ENSURE(pListBox != NULL); 43 | // fill with document templates in list 44 | 45 | POSITION pos = m_listItems.GetHeadPosition(); 46 | while (pos != NULL) 47 | { 48 | if ( pListBox->AddString(m_listItems.GetNext(pos)) == -1) 49 | return FALSE; 50 | } 51 | pListBox->SetCurSel(m_nSelection); 52 | 53 | return CDialog::OnInitDialog(); 54 | } 55 | 56 | void CListDlg::OnOK() 57 | { 58 | CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LISTDIALOG_LIST); 59 | ENSURE(pListBox != NULL); 60 | m_nSelection = pListBox->GetCurSel(); 61 | CDialog::OnOK(); 62 | } 63 | -------------------------------------------------------------------------------- /listdlg.h: -------------------------------------------------------------------------------- 1 | // This is a part of the Microsoft Foundation Classes C++ library. 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // This source code is only intended as a supplement to the 5 | // Microsoft Foundation Classes Reference and related 6 | // electronic documentation provided with the library. 7 | // See these sources for detailed information regarding the 8 | // Microsoft Foundation Classes product. 9 | 10 | class CListDlg : public CDialog 11 | { 12 | public: 13 | //{{AFX_DATA(CListDlg) 14 | enum { IDD = IDD_LISTDIALOG }; 15 | //}}AFX_DATA 16 | CListDlg::CListDlg(UINT idStrDlgTitle, UINT idStrListTitle, 17 | const CStringList& listItems, int nDefSel=0); 18 | CString m_strDlgTitle,m_strListTitle; 19 | const CStringList& m_listItems; 20 | int m_nSelection; 21 | 22 | protected: 23 | BOOL OnInitDialog(); 24 | //{{AFX_MSG(CListDlg) 25 | afx_msg void OnOK(); 26 | //}}AFX_MSG 27 | DECLARE_MESSAGE_MAP() 28 | }; 29 | -------------------------------------------------------------------------------- /mainfrm.cpp: -------------------------------------------------------------------------------- 1 | // mainfrm.cpp : implementation of the CMainFrame class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | 14 | #include "wordpad.h" 15 | #include "mainfrm.h" 16 | #include "wordpdoc.h" 17 | #include "wordpvw.h" 18 | #include "strings.h" 19 | #include "colorlis.h" 20 | 21 | #ifdef _DEBUG 22 | #undef THIS_FILE 23 | static char BASED_CODE THIS_FILE[] = __FILE__; 24 | #endif 25 | 26 | ///////////////////////////////////////////////////////////////////////////// 27 | // CMainFrame 28 | 29 | IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd) 30 | 31 | BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd) 32 | //{{AFX_MSG_MAP(CMainFrame) 33 | ON_WM_CREATE() 34 | ON_WM_SYSCOLORCHANGE() 35 | ON_WM_SIZE() 36 | ON_WM_MOVE() 37 | ON_COMMAND(ID_HELP, OnHelpFinder) 38 | ON_WM_DROPFILES() 39 | ON_COMMAND(ID_CHAR_COLOR, OnCharColor) 40 | ON_COMMAND(ID_PEN_TOGGLE, OnPenToggle) 41 | ON_WM_FONTCHANGE() 42 | ON_WM_QUERYNEWPALETTE() 43 | ON_WM_PALETTECHANGED() 44 | ON_WM_DEVMODECHANGE() 45 | ON_COMMAND(ID_HELP_INDEX, OnHelpFinder) 46 | //}}AFX_MSG_MAP 47 | // Global help commands 48 | // ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp) 49 | ON_COMMAND(ID_DEFAULT_HELP, OnHelpFinder) 50 | ON_UPDATE_COMMAND_UI(ID_VIEW_FORMATBAR, OnUpdateControlBarMenu) 51 | ON_UPDATE_COMMAND_UI(ID_VIEW_RULER, OnUpdateControlBarMenu) 52 | ON_MESSAGE(WPM_BARSTATE, OnBarState) 53 | ON_REGISTERED_MESSAGE(CWordPadApp::m_nOpenMsg, OnOpenMsg) 54 | ON_COMMAND_EX(ID_VIEW_STATUS_BAR, OnBarCheck) 55 | ON_COMMAND_EX(ID_VIEW_TOOLBAR, OnBarCheck) 56 | ON_COMMAND_EX(ID_VIEW_FORMATBAR, OnBarCheck) 57 | ON_COMMAND_EX(ID_VIEW_RULER, OnBarCheck) 58 | END_MESSAGE_MAP() 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // arrays of IDs used to initialize control bars 62 | 63 | // toolbar buttons - IDs are command buttons 64 | static UINT BASED_CODE toolbar[] = 65 | { 66 | // same order as in the bitmap 'toolbar.bmp' 67 | // (int nBitmap, int nCommand, BYTE byteState, BYTE byteStyle, DWORD dw, int nString) 68 | ID_FILE_NEW, 69 | ID_FILE_OPEN, 70 | ID_FILE_SAVE, 71 | ID_SEPARATOR, 72 | ID_FILE_PRINT_DIRECT, 73 | ID_FILE_PRINT_PREVIEW, 74 | ID_SEPARATOR, 75 | ID_EDIT_FIND, 76 | ID_SEPARATOR, 77 | ID_EDIT_CUT, 78 | ID_EDIT_COPY, 79 | ID_EDIT_PASTE, 80 | ID_EDIT_UNDO, 81 | ID_SEPARATOR, 82 | ID_INSERT_DATE_TIME, 83 | ID_SEPARATOR, 84 | ID_PEN_TOGGLE, 85 | ID_PEN_PERIOD, 86 | ID_PEN_SPACE, 87 | ID_PEN_BACKSPACE, 88 | ID_PEN_NEWLINE, 89 | ID_PEN_LENS 90 | }; 91 | 92 | #define NUM_PEN_ITEMS 7 93 | #define NUM_PEN_TOGGLE 5 94 | 95 | static UINT BASED_CODE format[] = 96 | { 97 | // same order as in the bitmap 'format.bmp' 98 | ID_SEPARATOR, // font name combo box 99 | ID_SEPARATOR, 100 | ID_SEPARATOR, // font size combo box 101 | ID_SEPARATOR, 102 | ID_CHAR_BOLD, 103 | ID_CHAR_ITALIC, 104 | ID_CHAR_UNDERLINE, 105 | ID_CHAR_COLOR, 106 | ID_SEPARATOR, 107 | ID_PARA_LEFT, 108 | ID_PARA_CENTER, 109 | ID_PARA_RIGHT, 110 | ID_SEPARATOR, 111 | ID_INSERT_BULLET, 112 | }; 113 | 114 | static UINT BASED_CODE indicators[] = 115 | { 116 | ID_SEPARATOR, // status line indicator 117 | ID_INDICATOR_CAPS, 118 | ID_INDICATOR_NUM, 119 | }; 120 | 121 | ///////////////////////////////////////////////////////////////////////////// 122 | // CMainFrame construction/destruction 123 | 124 | CMainFrame::CMainFrame() 125 | { 126 | m_hIconDoc = theApp.LoadIcon(IDI_ICON_DOC); 127 | m_hIconText = theApp.LoadIcon(IDI_ICON_TEXT); 128 | m_hIconWrite = theApp.LoadIcon(IDI_ICON_WRITE); 129 | } 130 | 131 | CMainFrame::~CMainFrame() 132 | { 133 | } 134 | 135 | BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 136 | { 137 | WNDCLASS wndcls; 138 | 139 | BOOL bRes = CFrameWnd::PreCreateWindow(cs); 140 | HINSTANCE hInst = AfxGetInstanceHandle(); 141 | 142 | // see if the class already exists 143 | if (!::GetClassInfo(hInst, szWordPadClass, &wndcls)) 144 | { 145 | // get default stuff 146 | ::GetClassInfo(hInst, cs.lpszClass, &wndcls); 147 | wndcls.style &= ~(CS_HREDRAW|CS_VREDRAW); 148 | // register a new class 149 | wndcls.lpszClassName = szWordPadClass; 150 | wndcls.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDR_MAINFRAME)); 151 | ASSERT(wndcls.hIcon != NULL); 152 | if (!AfxRegisterClass(&wndcls)) 153 | AfxThrowResourceException(); 154 | } 155 | cs.lpszClass = szWordPadClass; 156 | CRect rect = theApp.m_rectInitialFrame; 157 | if (rect.Width() > 0 && rect.Height() > 0) 158 | { 159 | // make sure window will be visible 160 | CDisplayIC dc; 161 | CRect rectDisplay(0, 0, dc.GetDeviceCaps(HORZRES), 162 | dc.GetDeviceCaps(VERTRES)); 163 | if (rectDisplay.PtInRect(rect.TopLeft()) && 164 | rectDisplay.PtInRect(rect.BottomRight())) 165 | { 166 | cs.x = rect.left; 167 | cs.y = rect.top; 168 | cs.cx = rect.Width(); 169 | cs.cy = rect.Height(); 170 | } 171 | } 172 | return bRes; 173 | } 174 | 175 | int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 176 | { 177 | if (CFrameWnd::OnCreate(lpCreateStruct) == -1) 178 | return -1; 179 | 180 | if (!CreateToolBar()) 181 | return -1; 182 | 183 | if (!CreateFormatBar()) 184 | return -1; 185 | 186 | if (!CreateStatusBar()) 187 | return -1; 188 | 189 | EnableDocking(CBRS_ALIGN_ANY); 190 | 191 | if (!CreateRulerBar()) 192 | return -1; 193 | 194 | m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 195 | m_wndFormatBar.EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM); 196 | DockControlBar(&m_wndToolBar); 197 | DockControlBar(&m_wndFormatBar); 198 | 199 | CWnd* pView = GetDlgItem(AFX_IDW_PANE_FIRST); 200 | if (pView != NULL) 201 | { 202 | pView->SetWindowPos(&wndBottom, 0, 0, 0, 0, 203 | SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE); 204 | } 205 | 206 | return 0; 207 | } 208 | 209 | BOOL CMainFrame::CreateToolBar() 210 | { 211 | int nPen = GetSystemMetrics(SM_PENWINDOWS) ? NUM_PEN_TOGGLE : 212 | NUM_PEN_ITEMS; 213 | UINT nID = theApp.m_bLargeIcons ? IDR_MAINFRAME1_BIG : 214 | IDR_MAINFRAME1; 215 | if (!m_wndToolBar.Create(this, 216 | WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)|| 217 | !m_wndToolBar.LoadBitmap(nID) || 218 | !m_wndToolBar.SetButtons(toolbar, sizeof(toolbar)/sizeof(UINT) - nPen)) 219 | { 220 | TRACE0("Failed to create toolbar\n"); 221 | return FALSE; // fail to create 222 | } 223 | if (theApp.m_bLargeIcons) 224 | m_wndToolBar.SetSizes(CSize(31,30), CSize(24,24)); 225 | else 226 | m_wndToolBar.SetSizes(CSize(23,22), CSize(16,16)); 227 | CString str; 228 | str.LoadString(IDS_TITLE_TOOLBAR); 229 | m_wndToolBar.SetWindowText(str); 230 | return TRUE; 231 | } 232 | 233 | BOOL CMainFrame::CreateFormatBar() 234 | { 235 | UINT nID = theApp.m_bLargeIcons ? IDB_FORMATBAR_BIG : IDB_FORMATBAR; 236 | if (!m_wndFormatBar.Create(this, 237 | WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC, 238 | ID_VIEW_FORMATBAR) || 239 | !m_wndFormatBar.LoadBitmap(nID) || 240 | !m_wndFormatBar.SetButtons(format, sizeof(format)/sizeof(UINT))) 241 | { 242 | TRACE0("Failed to create FormatBar\n"); 243 | return FALSE; // fail to create 244 | } 245 | 246 | if (theApp.m_bLargeIcons) 247 | m_wndFormatBar.SetSizes(CSize(31,30), CSize(24,24)); 248 | else 249 | m_wndFormatBar.SetSizes(CSize(23,22), CSize(16,16)); 250 | CString str; 251 | str.LoadString(IDS_TITLE_FORMATBAR); 252 | m_wndFormatBar.SetWindowText(str); 253 | m_wndFormatBar.PositionCombos(); 254 | return TRUE; 255 | } 256 | 257 | BOOL CMainFrame::CreateRulerBar() 258 | { 259 | if (!m_wndRulerBar.Create(this, 260 | WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_HIDE_INPLACE, ID_VIEW_RULER)) 261 | { 262 | TRACE0("Failed to create ruler\n"); 263 | return FALSE; // fail to create 264 | } 265 | return TRUE; 266 | } 267 | 268 | BOOL CMainFrame::CreateStatusBar() 269 | { 270 | if (!m_wndStatusBar.Create(this) || 271 | !m_wndStatusBar.SetIndicators(indicators, 272 | sizeof(indicators)/sizeof(UINT))) 273 | { 274 | TRACE0("Failed to create status bar\n"); 275 | return FALSE; // fail to create 276 | } 277 | return TRUE; 278 | } 279 | 280 | ///////////////////////////////////////////////////////////////////////////// 281 | // CMainFrame Operations 282 | 283 | HICON CMainFrame::GetIcon(int nDocType) 284 | { 285 | switch (nDocType) 286 | { 287 | case RD_WINWORD6: 288 | case RD_WORDPAD: 289 | case RD_EMBEDDED: 290 | case RD_RICHTEXT: 291 | return m_hIconDoc; 292 | case RD_TEXT: 293 | case RD_OEMTEXT: 294 | return m_hIconText; 295 | case RD_WRITE: 296 | return m_hIconWrite; 297 | } 298 | return m_hIconDoc; 299 | } 300 | 301 | ///////////////////////////////////////////////////////////////////////////// 302 | // CMainFrame diagnostics 303 | 304 | #ifdef _DEBUG 305 | void CMainFrame::AssertValid() const 306 | { 307 | CFrameWnd::AssertValid(); 308 | } 309 | 310 | void CMainFrame::Dump(CDumpContext& dc) const 311 | { 312 | CFrameWnd::Dump(dc); 313 | } 314 | 315 | #endif //_DEBUG 316 | 317 | ///////////////////////////////////////////////////////////////////////////// 318 | // CMainFrame message handlers 319 | 320 | void CMainFrame::OnFontChange() 321 | { 322 | m_wndFormatBar.SendMessage(CWordPadApp::m_nPrinterChangedMsg); 323 | } 324 | 325 | void CMainFrame::OnDevModeChange(LPTSTR lpDeviceName) 326 | { 327 | theApp.NotifyPrinterChanged(); 328 | CFrameWnd::OnDevModeChange(lpDeviceName); //sends message to descendants 329 | } 330 | 331 | void CMainFrame::OnSysColorChange() 332 | { 333 | CFrameWnd::OnSysColorChange(); 334 | m_wndRulerBar.SendMessage(WM_SYSCOLORCHANGE); 335 | } 336 | 337 | void CMainFrame::ActivateFrame(int nCmdShow) 338 | { 339 | CFrameWnd::ActivateFrame(nCmdShow); 340 | // make sure and display the toolbar, ruler, etc while loading a document. 341 | OnIdleUpdateCmdUI(); 342 | UpdateWindow(); 343 | } 344 | 345 | void CMainFrame::OnSize(UINT nType, int cx, int cy) 346 | { 347 | CFrameWnd::OnSize(nType, cx, cy); 348 | theApp.m_bMaximized = (nType == SIZE_MAXIMIZED); 349 | if (nType == SIZE_RESTORED) 350 | GetWindowRect(theApp.m_rectInitialFrame); 351 | } 352 | 353 | LONG_PTR CMainFrame::OnBarState(UINT_PTR wParam, LONG_PTR lParam) 354 | { 355 | if (lParam == -1) 356 | return 0L; 357 | ASSERT(lParam != RD_EMBEDDED); 358 | if (wParam == 0) 359 | { 360 | CDockState& ds = theApp.GetDockState(lParam); 361 | ds.Clear(); // empty out the dock state 362 | GetDockState(ds); 363 | } 364 | else 365 | { 366 | if (IsTextType(lParam)) 367 | { 368 | // in text mode hide the ruler and format bar so that it is the default 369 | CControlBar* pBar = GetControlBar(ID_VIEW_FORMATBAR); 370 | if (pBar != NULL) 371 | pBar->ShowWindow(SW_HIDE); 372 | pBar = GetControlBar(ID_VIEW_RULER); 373 | if (pBar != NULL) 374 | pBar->ShowWindow(SW_HIDE); 375 | } 376 | HICON hIcon = GetIcon((int)lParam); 377 | SendMessage(WM_SETICON, TRUE, (LPARAM)hIcon); 378 | SetDockState(theApp.GetDockState(lParam)); 379 | } 380 | return 0L; 381 | } 382 | 383 | void CMainFrame::OnMove(int x, int y) 384 | { 385 | CFrameWnd::OnMove(x, y); 386 | WINDOWPLACEMENT wp; 387 | wp.length = sizeof(wp); 388 | GetWindowPlacement(&wp); 389 | theApp.m_rectInitialFrame = wp.rcNormalPosition; 390 | CView* pView = GetActiveView(); 391 | if (pView != NULL) 392 | pView->SendMessage(WM_MOVE); 393 | } 394 | 395 | LONG_PTR CMainFrame::OnOpenMsg(UINT_PTR, LONG_PTR lParam) 396 | { 397 | TCHAR szAtomName[256]; 398 | szAtomName[0] = NULL; 399 | GlobalGetAtomName((ATOM)lParam, szAtomName, 256); 400 | CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument(); 401 | if (szAtomName[0] != NULL && pDoc != NULL) 402 | { 403 | if (lstrcmpi(szAtomName, pDoc->GetPathName()) == 0) 404 | return TRUE; 405 | } 406 | return FALSE; 407 | } 408 | 409 | void CMainFrame::OnHelpFinder() 410 | { 411 | theApp.WinHelp(0, HELP_FINDER); 412 | } 413 | 414 | void CMainFrame::OnDropFiles(HDROP hDropInfo) 415 | { 416 | TCHAR szFileName[_MAX_PATH]; 417 | ::DragQueryFile(hDropInfo, 0, szFileName, _MAX_PATH); 418 | ::DragFinish(hDropInfo); 419 | theApp.OpenDocumentFile(szFileName); 420 | } 421 | 422 | void CMainFrame::OnCharColor() 423 | { 424 | CColorMenu colorMenu; 425 | CRect rc; 426 | int index = m_wndFormatBar.CommandToIndex(ID_CHAR_COLOR); 427 | m_wndFormatBar.GetItemRect(index, &rc); 428 | m_wndFormatBar.ClientToScreen(rc); 429 | colorMenu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,rc.left,rc.bottom, this); 430 | } 431 | 432 | void CMainFrame::OnPenToggle() 433 | { 434 | static int nPen = 0; 435 | m_wndToolBar.SetButtons(toolbar, sizeof(toolbar)/sizeof(UINT) - nPen); 436 | nPen = (nPen == 0) ? NUM_PEN_TOGGLE : 0; 437 | m_wndToolBar.Invalidate(); 438 | m_wndToolBar.GetParentFrame()->RecalcLayout(); 439 | } 440 | 441 | BOOL CMainFrame::OnQueryNewPalette() 442 | { 443 | CView* pView = GetActiveView(); 444 | if (pView != NULL) 445 | return (BOOL)pView->SendMessage(WM_QUERYNEWPALETTE); 446 | return FALSE; 447 | } 448 | 449 | void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) 450 | { 451 | CView* pView = GetActiveView(); 452 | if (pView != NULL) 453 | pView->SendMessage(WM_PALETTECHANGED, (WPARAM)pFocusWnd->GetSafeHwnd()); 454 | } 455 | -------------------------------------------------------------------------------- /mainfrm.h: -------------------------------------------------------------------------------- 1 | // mainfrm.h : interface of the CMainFrame class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "formatba.h" 13 | #include "ruler.h" 14 | 15 | class CMainFrame : public CFrameWnd 16 | { 17 | protected: // create from serialization only 18 | CMainFrame(); 19 | DECLARE_DYNCREATE(CMainFrame) 20 | 21 | // Attributes 22 | public: 23 | HICON m_hIconDoc; 24 | HICON m_hIconText; 25 | HICON m_hIconWrite; 26 | HICON GetIcon(int nDocType); 27 | 28 | // Operations 29 | public: 30 | 31 | // Overrides 32 | // ClassWizard generated virtual function overrides 33 | //{{AFX_VIRTUAL(CMainFrame) 34 | public: 35 | virtual void ActivateFrame(int nCmdShow = -1); 36 | protected: 37 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 38 | //}}AFX_VIRTUAL 39 | 40 | // Implementation 41 | public: 42 | virtual ~CMainFrame(); 43 | #ifdef _DEBUG 44 | virtual void AssertValid() const; 45 | virtual void Dump(CDumpContext& dc) const; 46 | #endif 47 | 48 | public: 49 | CToolBar m_wndToolBar; 50 | CStatusBar m_wndStatusBar; 51 | CFormatBar m_wndFormatBar; 52 | CRulerBar m_wndRulerBar; 53 | protected: // control bar embedded members 54 | BOOL CreateToolBar(); 55 | BOOL CreateFormatBar(); 56 | BOOL CreateStatusBar(); 57 | BOOL CreateRulerBar(); 58 | // Generated message map functions 59 | protected: 60 | //{{AFX_MSG(CMainFrame) 61 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 62 | afx_msg void OnSysColorChange(); 63 | afx_msg void OnSize(UINT nType, int cx, int cy); 64 | afx_msg void OnMove(int x, int y); 65 | afx_msg void OnHelpFinder(); 66 | afx_msg void OnDropFiles(HDROP hDropInfo); 67 | afx_msg void OnCharColor(); 68 | afx_msg void OnPenToggle(); 69 | afx_msg void OnFontChange(); 70 | afx_msg BOOL OnQueryNewPalette(); 71 | afx_msg void OnPaletteChanged(CWnd* pFocusWnd); 72 | afx_msg void OnDevModeChange(LPTSTR lpDeviceName); 73 | //}}AFX_MSG 74 | afx_msg LONG_PTR OnBarState(UINT_PTR wParam, LONG_PTR lParam); 75 | afx_msg LONG_PTR OnOpenMsg(UINT_PTR wParam, LONG_PTR lParam); 76 | DECLARE_MESSAGE_MAP() 77 | }; 78 | -------------------------------------------------------------------------------- /mswd6_32.h: -------------------------------------------------------------------------------- 1 | // This is a part of the Microsoft Foundation Classes C++ library. 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // This source code is only intended as a supplement to the 5 | // Microsoft Foundation Classes Reference and related 6 | // electronic documentation provided with the library. 7 | // See these sources for detailed information regarding the 8 | // Microsoft Foundation Classes product. 9 | 10 | #ifndef MSWD6_32_H 11 | #define MSWD6_32_H 12 | 13 | typedef unsigned long (pascal *PFN_RTF_CALLBACK)(int, int); 14 | 15 | extern "C" int pascal InitConverter32(HANDLE, char *); 16 | extern "C" HANDLE pascal RegisterApp32(unsigned long, void *); 17 | extern "C" int pascal IsFormatCorrect32(HANDLE, HANDLE); 18 | extern "C" int pascal ForeignToRtf32(HANDLE, void *, HANDLE, HANDLE, HANDLE, PFN_RTF_CALLBACK); 19 | extern "C" int pascal RtfToForeign32(HANDLE, LPSTORAGE, HANDLE, HANDLE, PFN_RTF_CALLBACK); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /mswrd632.wpc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/mswrd632.wpc -------------------------------------------------------------------------------- /multconv.h: -------------------------------------------------------------------------------- 1 | // convert.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #ifdef CONVERTERS 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // CConverter 16 | 17 | typedef int (CALLBACK *LPFNOUT)(int cch, int nPercentComplete); 18 | typedef int (CALLBACK *LPFNIN)(int flags, int nPercentComplete); 19 | typedef BOOL (FAR PASCAL *PINITCONVERTER)(HWND hWnd, LPCSTR lpszModuleName); 20 | typedef BOOL (FAR PASCAL *PISFORMATCORRECT)(HANDLE ghszFile, HANDLE ghszClass); 21 | typedef int (FAR PASCAL *PFOREIGNTORTF)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff, 22 | HANDLE ghszClass, HANDLE ghszSubset, LPFNOUT lpfnOut); 23 | typedef int (FAR PASCAL *PRTFTOFOREIGN)(HANDLE ghszFile, LPVOID lpv, HANDLE ghBuff, 24 | HANDLE ghszClass, LPFNIN lpfnIn); 25 | 26 | #endif 27 | 28 | ///////////////////////////////////////////////////////////////////////////// 29 | // CTrackFile 30 | class CTrackFile : public CFile 31 | { 32 | public: 33 | //Construction 34 | CTrackFile(CFrameWnd* pWnd); 35 | ~CTrackFile(); 36 | 37 | //Attributes 38 | int m_nLastPercent; 39 | DWORD m_dwLength; 40 | CFrameWnd* m_pFrameWnd; 41 | CString m_strComplete; 42 | CString m_strWait; 43 | CString m_strSaving; 44 | //Operations 45 | void OutputPercent(int nPercentComplete = 0); 46 | void OutputString(LPCTSTR lpsz); 47 | virtual UINT Read(void FAR* lpBuf, UINT nCount); 48 | virtual void Write(const void FAR* lpBuf, UINT nCount); 49 | }; 50 | 51 | class COEMFile : public CTrackFile 52 | { 53 | public: 54 | COEMFile(CFrameWnd* pWnd); 55 | virtual UINT Read(void FAR* lpBuf, UINT nCount); 56 | virtual void Write(const void FAR* lpBuf, UINT nCount); 57 | }; 58 | 59 | #ifdef CONVERTERS 60 | 61 | class CConverter : public CTrackFile 62 | { 63 | public: 64 | CConverter(LPCSTR pszLibName, CFrameWnd* pWnd = NULL); 65 | protected: 66 | CConverter(CFrameWnd* pWnd = NULL); 67 | 68 | public: 69 | //Attributes 70 | int m_nPercent; 71 | BOOL m_bDone; 72 | BOOL m_bConvErr; 73 | virtual ULONGLONG GetPosition() const; 74 | 75 | // Operations 76 | BOOL IsFormatCorrect(LPCTSTR pszFileName); 77 | BOOL DoConversion(); 78 | virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, 79 | CFileException* pError = NULL); 80 | void WaitForConverter(); 81 | void WaitForBuffer(); 82 | 83 | // Overridables 84 | virtual ULONGLONG Seek(LONGLONG lOff, UINT nFrom); 85 | virtual ULONGLONG GetLength() const; 86 | 87 | virtual UINT Read(void* lpBuf, UINT nCount); 88 | virtual void Write(const void* lpBuf, UINT nCount); 89 | 90 | virtual void Abort(); 91 | virtual void Flush(); 92 | virtual void Close(); 93 | 94 | // Unsupported 95 | virtual CFile* Duplicate() const; 96 | virtual void LockRange(ULONGLONG dwPos, ULONGLONG dwCount); 97 | virtual void UnlockRange(ULONGLONG dwPos, ULONGLONG dwCount); 98 | virtual void SetLength(ULONGLONG dwNewLen); 99 | 100 | //Implementation 101 | public: 102 | ~CConverter(); 103 | 104 | protected: 105 | int m_nBytesAvail; 106 | int m_nBytesWritten; 107 | BYTE* m_pBuf; 108 | HANDLE m_hEventFile; 109 | HANDLE m_hEventConv; 110 | BOOL m_bForeignToRtf; 111 | HGLOBAL m_hBuff; 112 | HGLOBAL m_hFileName; 113 | void LoadFunctions(); 114 | HINSTANCE m_hLibCnv; 115 | PINITCONVERTER m_pInitConverter; 116 | PISFORMATCORRECT m_pIsFormatCorrect; 117 | PFOREIGNTORTF m_pForeignToRtf; 118 | PRTFTOFOREIGN m_pRtfToForeign; 119 | int CALLBACK WriteOut(int cch, int nPercentComplete); 120 | int CALLBACK ReadIn(int nPercentComplete); 121 | static HGLOBAL StringToHGLOBAL(LPCSTR pstr); 122 | static int CALLBACK WriteOutStatic(int cch, int nPercentComplete); 123 | static int CALLBACK ReadInStatic(int flags, int nPercentComplete); 124 | static UINT ConverterThread(LPVOID pParam); 125 | static CConverter *m_pThis; 126 | }; 127 | 128 | #endif 129 | 130 | ///////////////////////////////////////////////////////////////////////////// 131 | -------------------------------------------------------------------------------- /options.cpp: -------------------------------------------------------------------------------- 1 | // options.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "strings.h" 15 | 16 | #ifdef _DEBUG 17 | #undef THIS_FILE 18 | static char BASED_CODE THIS_FILE[] = __FILE__; 19 | #endif 20 | 21 | ///////////////////////////////////////////////////////////////////////////// 22 | // CDocOptions 23 | 24 | void CDocOptions::SaveDockState(CDockState& ds, LPCTSTR lpszProfileName, LPCTSTR lpszLayout) 25 | { 26 | CMemFile file; 27 | CArchive ar(&file, CArchive::store); 28 | ds.Serialize(ar); 29 | ar.Close(); 30 | int nSize = (int)file.GetLength(); 31 | ASSERT(nSize < 4096); 32 | BYTE* p = new BYTE[nSize]; 33 | file.SeekToBegin(); 34 | file.Read(p, nSize); 35 | theApp.WriteProfileBinary(lpszProfileName, lpszLayout, p, nSize); 36 | delete [] p; 37 | } 38 | 39 | void CDocOptions::SaveOptions(LPCTSTR lpszProfileName) 40 | { 41 | SaveDockState(m_ds1, lpszProfileName, szLayout1); 42 | SaveDockState(m_ds2, lpszProfileName, szLayout2); 43 | theApp.WriteProfileInt(lpszProfileName, szWrap, m_nWordWrap); 44 | } 45 | 46 | void CDocOptions::LoadDockState(CDockState& ds, LPCTSTR lpszProfileName, LPCTSTR lpszLayout) 47 | { 48 | BYTE* p; 49 | UINT nLen = 0; 50 | if (theApp.GetProfileBinary(lpszProfileName, lpszLayout, &p, &nLen)) 51 | { 52 | ASSERT(nLen < 4096); 53 | CMemFile file; 54 | file.Write(p, nLen); 55 | file.SeekToBegin(); 56 | CArchive ar(&file, CArchive::load); 57 | ds.Serialize(ar); 58 | ar.Close(); 59 | delete p; 60 | } 61 | } 62 | 63 | void CDocOptions::LoadOptions(LPCTSTR lpszProfileName) 64 | { 65 | LoadDockState(m_ds1, lpszProfileName, szLayout1); 66 | LoadDockState(m_ds2, lpszProfileName, szLayout2); 67 | m_nWordWrap = theApp.GetProfileInt(lpszProfileName, szWrap, m_nDefWrap); 68 | } 69 | 70 | ///////////////////////////////////////////////////////////////////////////// 71 | // CUnit 72 | 73 | const CUnit& CUnit::operator=(const CUnit& unit) 74 | { 75 | m_nTPU = unit.m_nTPU; 76 | m_nSmallDiv = unit.m_nSmallDiv; 77 | m_nMediumDiv = unit.m_nMediumDiv; 78 | m_nLargeDiv = unit.m_nLargeDiv; 79 | m_nMinMove = unit.m_nMinMove; 80 | m_nAbbrevID = unit.m_nAbbrevID; 81 | m_bSpaceAbbrev = unit.m_bSpaceAbbrev; 82 | m_strAbbrev = unit.m_strAbbrev; 83 | return *this; 84 | } 85 | 86 | CUnit::CUnit(int nTPU, int nSmallDiv, int nMediumDiv, int nLargeDiv, 87 | int nMinMove, UINT nAbbrevID, BOOL bSpaceAbbrev) 88 | { 89 | m_nTPU = nTPU; 90 | m_nSmallDiv = nSmallDiv; 91 | m_nMediumDiv = nMediumDiv; 92 | m_nLargeDiv = nLargeDiv; 93 | m_nMinMove = nMinMove; 94 | m_nAbbrevID = nAbbrevID; 95 | m_bSpaceAbbrev = bSpaceAbbrev; 96 | } 97 | -------------------------------------------------------------------------------- /options.h: -------------------------------------------------------------------------------- 1 | // options.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | class CUnit 13 | { 14 | public: 15 | int m_nTPU; 16 | int m_nSmallDiv; // small divisions - small line displayed 17 | int m_nMediumDiv; // medium divisions - large line displayed 18 | int m_nLargeDiv; // large divisions - numbers displayed 19 | int m_nMinMove; // minimum tracking movements 20 | UINT m_nAbbrevID; 21 | BOOL m_bSpaceAbbrev; // put space before abbreviation 22 | CString m_strAbbrev;// cm, pt, pi, ", in, inch, inches 23 | 24 | CUnit() {} 25 | CUnit(int nTPU, int nSmallDiv, int nMediumDiv, int nLargeDiv, 26 | int nMinMove, UINT nAbbrevID, BOOL bSpaceAbbrev); 27 | const CUnit& operator=(const CUnit& unit); 28 | }; 29 | 30 | class CDocOptions 31 | { 32 | public: 33 | CDocOptions(int nDefWrap) {m_nDefWrap = nDefWrap;} 34 | CDockState m_ds1; 35 | CDockState m_ds2; 36 | int m_nWordWrap; 37 | int m_nDefWrap; 38 | void SaveOptions(LPCTSTR lpsz); 39 | void LoadOptions(LPCTSTR lpsz); 40 | void SaveDockState(CDockState& ds, LPCTSTR lpszProfileName, 41 | LPCTSTR lpszLayout); 42 | void LoadDockState(CDockState& ds, LPCTSTR lpszProfileName, 43 | LPCTSTR lpszLayout); 44 | CDockState& GetDockState(BOOL bPrimary) {return (bPrimary) ? m_ds1 : m_ds2;} 45 | }; 46 | 47 | ///////////////////////////////////////////////////////////////////////////// 48 | -------------------------------------------------------------------------------- /optionsh.cpp: -------------------------------------------------------------------------------- 1 | // optionsh.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "unitspag.h" 15 | #include "docopt.h" 16 | #include "optionsh.h" 17 | 18 | #ifdef _DEBUG 19 | #undef THIS_FILE 20 | static char BASED_CODE THIS_FILE[] = __FILE__; 21 | #endif 22 | 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // COptionSheet 25 | 26 | COptionSheet::COptionSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage) 27 | : CCSPropertySheet(nIDCaption, pParentWnd, iSelectPage), 28 | pageText(IDS_TEXT_OPTIONS), pageRTF(IDS_RTF_OPTIONS), 29 | pageWord(IDS_WORD6_OPTIONS), pageWrite(IDS_WRITE_OPTIONS), 30 | pageEmbedded() 31 | { 32 | units.m_nUnits = theApp.GetUnits(); 33 | units.m_bWordSel = theApp.m_bWordSel; 34 | pageText.m_nWordWrap = theApp.GetDocOptions(RD_TEXT).m_nWordWrap; 35 | pageRTF.m_nWordWrap = theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap; 36 | pageWord.m_nWordWrap = theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap; 37 | pageWrite.m_nWordWrap = theApp.GetDocOptions(RD_WRITE).m_nWordWrap; 38 | pageEmbedded.m_nWordWrap = theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap; 39 | SetPageButtons(pageText, theApp.GetDockState(RD_TEXT)); 40 | SetPageButtons(pageRTF, theApp.GetDockState(RD_RICHTEXT)); 41 | SetPageButtons(pageWord, theApp.GetDockState(RD_WINWORD6)); 42 | SetPageButtons(pageWrite, theApp.GetDockState(RD_WRITE)); 43 | SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED)); 44 | SetPageButtons(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE)); 45 | AddPage(&units); 46 | AddPage(&pageText); 47 | AddPage(&pageRTF); 48 | AddPage(&pageWord); 49 | AddPage(&pageWrite); 50 | AddPage(&pageEmbedded); 51 | } 52 | 53 | void COptionSheet::SetPageButtons(CDocOptPage& page, CDockState& ds) 54 | { 55 | if (ds.m_arrBarInfo.GetSize() == 0) 56 | { 57 | page.m_bFormatBar = page.m_bRulerBar = TRUE; 58 | page.m_bToolBar = page.m_bStatusBar = TRUE; 59 | } 60 | else 61 | { 62 | for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++) 63 | { 64 | CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i]; 65 | ENSURE(pInfo != NULL); 66 | switch (pInfo->m_nBarID) 67 | { 68 | case ID_VIEW_FORMATBAR: 69 | page.m_bFormatBar = page.m_bFormatBar || pInfo->m_bVisible; 70 | break; 71 | case ID_VIEW_RULER: 72 | page.m_bRulerBar = page.m_bRulerBar || pInfo->m_bVisible; 73 | break; 74 | case ID_VIEW_TOOLBAR: 75 | page.m_bToolBar = page.m_bToolBar || pInfo->m_bVisible; 76 | break; 77 | case ID_VIEW_STATUS_BAR: 78 | page.m_bStatusBar = page.m_bStatusBar || pInfo->m_bVisible; 79 | break; 80 | } 81 | } 82 | } 83 | } 84 | 85 | void COptionSheet::SetState(CDocOptPage& page, CDockState& ds) 86 | { 87 | for (int i = 0;i < ds.m_arrBarInfo.GetSize(); i++) 88 | { 89 | CControlBarInfo* pInfo = (CControlBarInfo*)ds.m_arrBarInfo[i]; 90 | ENSURE(pInfo != NULL); 91 | switch (pInfo->m_nBarID) 92 | { 93 | case ID_VIEW_FORMATBAR: 94 | pInfo->m_bVisible = page.m_bFormatBar; 95 | break; 96 | case ID_VIEW_RULER: 97 | pInfo->m_bVisible = page.m_bRulerBar; 98 | break; 99 | case ID_VIEW_TOOLBAR: 100 | pInfo->m_bVisible = page.m_bToolBar; 101 | break; 102 | case ID_VIEW_STATUS_BAR: 103 | pInfo->m_bVisible = page.m_bStatusBar; 104 | break; 105 | } 106 | } 107 | } 108 | 109 | BEGIN_MESSAGE_MAP(COptionSheet, CCSPropertySheet) 110 | //{{AFX_MSG_MAP(COptionSheet) 111 | ON_WM_CREATE() 112 | //}}AFX_MSG_MAP 113 | END_MESSAGE_MAP() 114 | 115 | 116 | ///////////////////////////////////////////////////////////////////////////// 117 | // COptionSheet message handlers 118 | 119 | INT_PTR COptionSheet::DoModal() 120 | { 121 | INT_PTR nRes = CCSPropertySheet::DoModal(); 122 | if (nRes == IDOK) 123 | { 124 | SetState(pageText, theApp.GetDockState(RD_TEXT)); 125 | SetState(pageRTF, theApp.GetDockState(RD_RICHTEXT)); 126 | SetState(pageWord, theApp.GetDockState(RD_WINWORD6)); 127 | SetState(pageWrite, theApp.GetDockState(RD_WRITE)); 128 | SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED)); 129 | SetState(pageEmbedded, theApp.GetDockState(RD_EMBEDDED, FALSE)); 130 | theApp.SetUnits(units.m_nUnits); 131 | theApp.m_bWordSel = units.m_bWordSel; 132 | theApp.GetDocOptions(RD_TEXT).m_nWordWrap = pageText.m_nWordWrap; 133 | theApp.GetDocOptions(RD_RICHTEXT).m_nWordWrap = pageRTF.m_nWordWrap; 134 | theApp.GetDocOptions(RD_WINWORD6).m_nWordWrap = pageWord.m_nWordWrap; 135 | theApp.GetDocOptions(RD_WRITE).m_nWordWrap = pageWrite.m_nWordWrap; 136 | theApp.GetDocOptions(RD_EMBEDDED).m_nWordWrap = pageEmbedded.m_nWordWrap; 137 | } 138 | return nRes; 139 | } 140 | 141 | ///////////////////////////////////////////////////////////////////////////// 142 | // COptionSheet message handlers 143 | -------------------------------------------------------------------------------- /optionsh.h: -------------------------------------------------------------------------------- 1 | // optionsh.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // COptionSheet 14 | 15 | class COptionSheet : public CCSPropertySheet 16 | { 17 | // Construction 18 | public: 19 | COptionSheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); 20 | 21 | // Attributes 22 | public: 23 | CUnitsPage units; 24 | CDocOptPage pageText; 25 | CDocOptPage pageRTF; 26 | CDocOptPage pageWord; 27 | CDocOptPage pageWrite; 28 | CEmbeddedOptPage pageEmbedded; 29 | 30 | // Operations 31 | public: 32 | INT_PTR DoModal(); 33 | void SetPageButtons(CDocOptPage& page, CDockState& ds); 34 | void SetState(CDocOptPage& page, CDockState& ds); 35 | 36 | // Overrides 37 | // ClassWizard generated virtual function overrides 38 | //{{AFX_VIRTUAL(COptionSheet) 39 | //}}AFX_VIRTUAL 40 | 41 | // Implementation 42 | public: 43 | 44 | // Generated message map functions 45 | protected: 46 | //{{AFX_MSG(COptionSheet) 47 | //}}AFX_MSG 48 | DECLARE_MESSAGE_MAP() 49 | }; 50 | 51 | ///////////////////////////////////////////////////////////////////////////// 52 | -------------------------------------------------------------------------------- /pageset.cpp: -------------------------------------------------------------------------------- 1 | // pageset.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "resource.h" 15 | #include "pageset.h" 16 | #include "ruler.h" 17 | #include "ddxm.h" 18 | #include "helpids.h" 19 | 20 | #ifdef _DEBUG 21 | #undef THIS_FILE 22 | static char BASED_CODE THIS_FILE[] = __FILE__; 23 | #endif 24 | 25 | ///////////////////////////////////////////////////////////////////////////// 26 | // CPageSetupDlg dialog 27 | 28 | const DWORD CPageSetupDlg::m_nHelpIDs[] = 29 | { 30 | IDC_EDIT_TM, IDH_WORDPAD_TOPMARGIN, 31 | IDC_EDIT_BM, IDH_WORDPAD_BOTTOMMARGIN, 32 | IDC_EDIT_LM, IDH_WORDPAD_LEFTMARGIN, 33 | IDC_EDIT_RM, IDH_WORDPAD_RIGHTMARGIN, 34 | IDC_BOX, IDH_COMM_GROUPBOX, 35 | 0, 0 36 | }; 37 | 38 | CPageSetupDlg::CPageSetupDlg(CWnd* pParent /*=NULL*/) 39 | : CCSDialog(CPageSetupDlg::IDD, pParent) 40 | { 41 | //{{AFX_DATA_INIT(CPageSetupDlg) 42 | m_nTopMargin = 0; 43 | m_nRightMargin = 0; 44 | m_nLeftMargin = 0; 45 | m_nBottomMargin = 0; 46 | //}}AFX_DATA_INIT 47 | } 48 | 49 | void CPageSetupDlg::DoDataExchange(CDataExchange* pDX) 50 | { 51 | CCSDialog::DoDataExchange(pDX); 52 | //{{AFX_DATA_MAP(CPageSetupDlg) 53 | DDX_Twips(pDX, IDC_EDIT_TM, m_nTopMargin); 54 | DDV_MinMaxTwips(pDX, m_nTopMargin, -31680, 31680); 55 | DDX_Twips(pDX, IDC_EDIT_RM, m_nRightMargin); 56 | DDV_MinMaxTwips(pDX, m_nRightMargin, -31680, 31680); 57 | DDX_Twips(pDX, IDC_EDIT_LM, m_nLeftMargin); 58 | DDV_MinMaxTwips(pDX, m_nLeftMargin, -31680, 31680); 59 | DDX_Twips(pDX, IDC_EDIT_BM, m_nBottomMargin); 60 | DDV_MinMaxTwips(pDX, m_nBottomMargin, -31680, 31680); 61 | //}}AFX_DATA_MAP 62 | } 63 | 64 | BEGIN_MESSAGE_MAP(CPageSetupDlg, CCSDialog) 65 | //{{AFX_MSG_MAP(CPageSetupDlg) 66 | //}}AFX_MSG_MAP 67 | END_MESSAGE_MAP() 68 | 69 | ///////////////////////////////////////////////////////////////////////////// 70 | // CPageSetupDlg message handlers 71 | -------------------------------------------------------------------------------- /pageset.h: -------------------------------------------------------------------------------- 1 | // pageset.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CPageSetupDlg dialog 14 | 15 | class CPageSetupDlg : public CCSDialog 16 | { 17 | // Construction 18 | public: 19 | CPageSetupDlg(CWnd* pParent = NULL); // standard constructor 20 | 21 | // Dialog Data 22 | //{{AFX_DATA(CPageSetupDlg) 23 | enum { IDD = IDD_PAGE_SETUP_DIALOG }; 24 | int m_nTopMargin; 25 | int m_nRightMargin; 26 | int m_nLeftMargin; 27 | int m_nBottomMargin; 28 | //}}AFX_DATA 29 | 30 | // Implementation 31 | static const DWORD m_nHelpIDs[]; 32 | virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} 33 | protected: 34 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 35 | 36 | // Generated message map functions 37 | //{{AFX_MSG(CPageSetupDlg) 38 | //}}AFX_MSG 39 | DECLARE_MESSAGE_MAP() 40 | }; 41 | -------------------------------------------------------------------------------- /res/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/font.bmp -------------------------------------------------------------------------------- /res/formatba.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/formatba.bmp -------------------------------------------------------------------------------- /res/formatbg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/formatbg.bmp -------------------------------------------------------------------------------- /res/main1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/main1.bmp -------------------------------------------------------------------------------- /res/main1b.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/main1b.bmp -------------------------------------------------------------------------------- /res/mainfrm.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/mainfrm.bmp -------------------------------------------------------------------------------- /res/mainfrmb.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/mainfrmb.bmp -------------------------------------------------------------------------------- /res/rtfdoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rtfdoc.ico -------------------------------------------------------------------------------- /res/rulerbl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulerbl.bmp -------------------------------------------------------------------------------- /res/rulerblm.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulerblm.bmp -------------------------------------------------------------------------------- /res/rulerdo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulerdo.bmp -------------------------------------------------------------------------------- /res/rulerdom.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulerdom.bmp -------------------------------------------------------------------------------- /res/rulerta.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulerta.bmp -------------------------------------------------------------------------------- /res/rulertam.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulertam.bmp -------------------------------------------------------------------------------- /res/rulerup.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulerup.bmp -------------------------------------------------------------------------------- /res/rulerupm.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/rulerupm.bmp -------------------------------------------------------------------------------- /res/srvr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/srvr.bmp -------------------------------------------------------------------------------- /res/srvrbig.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/srvrbig.bmp -------------------------------------------------------------------------------- /res/textdoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/textdoc.ico -------------------------------------------------------------------------------- /res/wordp48.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/wordp48.bmp -------------------------------------------------------------------------------- /res/wordpad.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/wordpad.ico -------------------------------------------------------------------------------- /res/wordpad.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // WORDPAD.RC2 - resources App Studio does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by App Studio 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // Add manually edited resources here... 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /res/write.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/res/write.ico -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by WordPad.rc 4 | // 5 | #define IDR_SRVR_INPLACE 4 6 | #define IDR_SRVR_EMBEDDED 5 7 | #define IDR_CNTR_INPLACE 6 8 | #define IDP_OLE_INIT_FAILED 100 9 | #define IDP_FAILED_TO_CREATE 102 10 | #define IDS_INVALID_MEASUREMENT 103 11 | #define IDS_PLEASE_WAIT 104 12 | #define IDS_COMPLETE 105 13 | #define IDS_SAVE_UNSUPPORTED 106 14 | #define IDS_CLOSE_TEXT 107 15 | #define IDS_RICHED_LOAD_FAIL 108 16 | #define IDS_DEFAULTFONT 109 17 | #define IDS_TF_BUTTONS 110 18 | #define IDC_COMBO_ALIGNMENT 111 19 | #define IDS_DEFAULTTEXTFONT 111 20 | #define IDS_SAVE_FORMAT_TEXT 112 21 | #define IDS_SAVE_FORMAT 113 22 | #define IDS_SAVING 113 23 | #define IDS_CLIP_RTF 114 24 | #define IDS_FORMATTING 115 25 | #define IDS_LEFT 116 26 | #define IDS_CENTER 117 27 | #define IDS_RIGHT 118 28 | #define IDS_NOWRAP 119 29 | #define IDS_MEASUREMENT_RANGE 119 30 | #define IDS_WRAPTOWINDOW 120 31 | #define IDS_INVALID_NUMBER 120 32 | #define IDS_WRAPTORULER 121 33 | #define IDS_INVALID_FONTSIZE 121 34 | #define IDS_INCHES 122 35 | #define IDS_CENTIMETERS 123 36 | #define IDS_POINTS 124 37 | #define IDS_PICAS 125 38 | #define IDS_WORD6_WARNING 126 39 | #define IDS_WORD6_WARNING_BUTTONS 127 40 | #define IDR_MAINFRAME 128 41 | #define IDS_TEXT_DOC 129 42 | #define IDS_RICHTEXT_DOC 130 43 | #define IDB_BITMAP_TT 130 44 | #define IDS_WRITE_DOC 131 45 | #define IDB_RULER_BLOCK 131 46 | #define IDS_ALL_DOC 132 47 | #define IDB_RULER_BLOCKM 132 48 | #define IDS_WINWORD6_DOC 133 49 | #define IDB_RULER_DOWN 133 50 | #define IDS_WINWORD2_DOC 134 51 | #define IDB_RULER_DOWNM 134 52 | #define IDB_RULER_TAB 135 53 | #define IDS_EXE_DOC 135 54 | #define IDB_RULER_TABM 136 55 | #define IDS_FILE_EXISTS 136 56 | #define IDB_RULER_UP 137 57 | #define IDS_MAPILOAD_FAILED 137 58 | #define IDS_OEMTEXT_DOC 137 59 | #define IDB_RULER_UPM 138 60 | #define IDS_CLIP_TEXT 138 61 | #define IDB_FORMATBAR 139 62 | #define IDS_CLIP_FILENAME 139 63 | #define IDR_MAINFRAME1 140 64 | #define IDB_FORMATBAR_BIG 141 65 | #define IDR_COLOR_MENU 142 66 | #define IDR_MAINFRAME_BIG 142 67 | #define IDD_FORMAT_PARA 143 68 | #define IDR_MAINFRAME1_BIG 143 69 | #define IDR_SRVR_INPLACE_BIG 144 70 | #define IDD_FORMAT_TAB 145 71 | #define IDD_LISTDIALOG 147 72 | #define IDD_OPTIONS 148 73 | #define IDS_DT1 149 74 | #define IDD_PAGE_SETUP_DIALOG 150 75 | #define IDS_DT2 150 76 | #define IDR_MENU1 151 77 | #define IDS_DT3 151 78 | #define IDD_DATEDIALOG 151 79 | #define IDS_DT4 152 80 | #define IDR_TEXT_POPUP 152 81 | #define IDS_DT5 153 82 | #define IDS_DT6 154 83 | #define IDI_ICON_DOC 154 84 | #define IDS_DT7 155 85 | #define IDI_ICON_WRITE 155 86 | #define IDS_DT8 156 87 | #define IDS_DT9 157 88 | #define IDD_SPLASH 157 89 | #define IDS_DT10 158 90 | #define IDD_OPTIONS_UNITS 158 91 | #define IDS_DT11 159 92 | #define IDD_OPTIONS_WRAP 159 93 | #define IDS_DT12 160 94 | #define IDD_OPTIONS_MARGINS 160 95 | #define IDD_FILENEWDIALOG 160 96 | #define IDS_DT13 161 97 | #define IDB_BITMAP48 162 98 | #define IDB_BITMAP_PRINTER 163 99 | #define IDS_FINISHED_SEARCH 164 100 | #define IDC_FONTNAME 165 101 | #define IDI_ICON_TEXT 165 102 | #define IDC_FONTSIZE 166 103 | #define IDS_TITLE_FORMATBAR 167 104 | #define IDB_PRINTER 167 105 | #define IDB_FONTTYPE 167 106 | #define IDS_TITLE_TOOLBAR 168 107 | #define IDS_INCH1_ABBREV 169 108 | #define IDS_INCH2_ABBREV 170 109 | #define IDS_INCH3_ABBREV 171 110 | #define IDS_INCH4_ABBREV 172 111 | #define IDS_CM_ABBREV 173 112 | #define IDS_POINT_ABBREV 174 113 | #define IDS_PICA_ABBREV 175 114 | #define IDS_NOMORETABS 176 115 | #define IDS_MAPI_FAIL 177 116 | #define IDS_ERRSPACE 178 117 | #define IDS_CANT_LOAD 179 118 | #define IDS_TOOMANYFILES 180 119 | #define IDS_DIRFULL 181 120 | #define IDS_SHAREVIOLATION 182 121 | #define IDS_TEXT_OPTIONS 183 122 | #define IDS_RTF_OPTIONS 184 123 | #define IDS_WORD6_OPTIONS 185 124 | #define IDS_OPTIONS 186 125 | #define IDS_WRITE_OPTIONS 187 126 | #define IDS_EMBEDDED_OPTIONS 188 127 | #define IDS_TEXT_DOCUMENT 189 128 | #define IDS_RTF_DOCUMENT 190 129 | #define IDS_WORD6_DOCUMENT 191 130 | #define IDS_WRITEPROTECT 192 131 | #define IDC_EDIT_LEFT 1000 132 | #define IDC_EDIT_RIGHT 1001 133 | #define IDC_EDIT_FIRST_LINE 1002 134 | #define IDC_BUTTON_SET 1005 135 | #define IDC_EDIT_BM 1005 136 | #define IDC_BUTTON_CLEAR 1006 137 | #define IDC_EDIT_LM 1006 138 | #define IDC_BUTTON_CLEARALL 1007 139 | #define IDC_EDIT_RM 1007 140 | #define IDC_STATIC_HEADING 1009 141 | #define IDC_COMBO_WRAP 1011 142 | #define IDC_COMBO_UNITS 1012 143 | #define IDC_EDIT_TM 1016 144 | #define IDC_TEXT_ALIGNMENT 1017 145 | #define IDC_LISTDIALOG_LIST 1018 146 | #define IDC_DATEDIALOG_LIST 1018 147 | #define IDC_COMBO1 1019 148 | #define IDC_TEXT_WRAP 1020 149 | #define IDC_TEXT_UNITS 1021 150 | #define IDC_BOX 1022 151 | #define IDC_BIGICON 1023 152 | #define IDC_UNITS_IN 1024 153 | #define IDC_UNITS_CM 1025 154 | #define IDC_WRAP_RULER 1025 155 | #define IDC_UNITS_PT 1026 156 | #define IDC_WRAP_WINDOW 1026 157 | #define IDC_UNITS_PI 1027 158 | #define IDC_WRAP_NONE 1027 159 | #define IDC_CHECK_TOOLBAR 1028 160 | #define IDC_CHECK_FORMATBAR 1029 161 | #define IDC_WORDSEL 1029 162 | #define IDC_CHECK_RULERBAR 1030 163 | #define IDC_CHECK_STATUSBAR 1031 164 | #define IDC_BOXT 1032 165 | #define IDC_CHECK_PAGEBREAK 1033 166 | #define IDC_EDIT_BEFORE 1035 167 | #define IDC_EDIT_AFTER 1036 168 | #define IDC_SPIN_BEFORE 1038 169 | #define IDC_SPIN_AFTER 1039 170 | #define ID_CANCEL_EDIT_CNTR 32768 171 | #define ID_CANCEL_EDIT_SRVR 32769 172 | #define ID_PAGE_SETUP 32771 173 | #define ID_VIEW_OPTIONS 32776 174 | #define ID_INSERT_BULLET 32777 175 | #define ID_INSERT_DATE_TIME 32778 176 | #define ID_FORMAT_PARAGRAPH 32780 177 | #define ID_FORMAT_TABS 32781 178 | #define ID_COLOR0 32782 179 | #define ID_COLOR1 32783 180 | #define ID_COLOR2 32784 181 | #define ID_COLOR3 32785 182 | #define ID_COLOR4 32786 183 | #define ID_COLOR5 32787 184 | #define ID_COLOR6 32788 185 | #define ID_COLOR7 32789 186 | #define ID_COLOR8 32790 187 | #define ID_COLOR9 32791 188 | #define ID_COLOR10 32792 189 | #define ID_COLOR11 32793 190 | #define ID_COLOR12 32794 191 | #define ID_COLOR13 32795 192 | #define ID_COLOR14 32796 193 | #define ID_COLOR15 32797 194 | #define ID_COLOR16 32798 195 | #define ID_CHAR_BOLD 32799 196 | #define ID_CHAR_ITALIC 32800 197 | #define ID_CHAR_COLOR 32801 198 | #define ID_CHAR_UNDERLINE 32802 199 | #define ID_PARA_LEFT 32803 200 | #define ID_PARA_CENTER 32804 201 | #define ID_PARA_RIGHT 32805 202 | #define ID_PEN_PERIOD 32807 203 | #define ID_PEN_SPACE 32808 204 | #define ID_PEN_BACKSPACE 32809 205 | #define ID_PEN_NEWLINE 32810 206 | #ifndef ID_OLE_VERB_POPUP 207 | #define ID_OLE_VERB_POPUP 32811 208 | #endif 209 | #define ID_PEN_TOGGLE 32812 210 | #define ID_PEN_LENS 32813 211 | #define ID_PEN_TAB 32814 212 | #define ID_VIEW_FORMATBAR 59396 213 | #define ID_VIEW_RULER 59397 214 | 215 | // Next default values for new objects 216 | // 217 | #ifdef APSTUDIO_INVOKED 218 | #ifndef APSTUDIO_READONLY_SYMBOLS 219 | #define _APS_3D_CONTROLS 1 220 | #define _APS_NEXT_RESOURCE_VALUE 172 221 | #define _APS_NEXT_COMMAND_VALUE 32816 222 | #define _APS_NEXT_CONTROL_VALUE 1040 223 | #define _APS_NEXT_SYMED_VALUE 103 224 | #endif 225 | #endif 226 | -------------------------------------------------------------------------------- /ruler.h: -------------------------------------------------------------------------------- 1 | // riched.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #ifndef __RULER_H__ 13 | #define __RULER_H__ 14 | 15 | class CWordPadView; 16 | class CWordPadDoc; 17 | class CRulerBar; 18 | 19 | // ruler items include left margin, right margin, indent, and tabs 20 | 21 | // horz positions in twips -- necessary to avoid rounding errors 22 | // vertical position in pixels 23 | class CRulerItem 24 | { 25 | public: 26 | CRulerItem(UINT nBitmapID = 0); 27 | ~CRulerItem(); 28 | virtual BOOL HitTestPix(CPoint pt) { return GetHitRectPix().PtInRect(pt); } 29 | virtual void Draw(CDC& dc); 30 | virtual void SetHorzPosTwips(int nXPos); 31 | virtual void TrackHorzPosTwips(int nXPos, BOOL bOnRuler = TRUE); 32 | virtual void SetVertPos(int nYPos) { m_nYPosPix = nYPos; } 33 | virtual void SetAlignment(int nAlign) {m_nAlignment = nAlign;} 34 | virtual void SetRuler(CRulerBar* pRuler) {m_pRuler = pRuler;} 35 | virtual void SetBounds(int nMin, int nMax) { m_nMin = nMin; m_nMax = nMax; } 36 | int GetMin() { return m_nMin;} 37 | int GetMax() { return m_nMax;} 38 | void Invalidate(); 39 | int GetVertPosPix() { return m_nYPosPix;} 40 | int GetHorzPosTwips() { return m_nXPosTwips;} 41 | int GetHorzPosPix(); 42 | CRect GetHitRectPix(); 43 | void DrawFocusLine(); 44 | void SetTrack(BOOL b); 45 | 46 | HBITMAP m_hbm; 47 | HBITMAP m_hbmMask; 48 | CSize m_size; // size of item in pixels 49 | 50 | // Operations 51 | BOOL LoadMaskedBitmap(LPCTSTR lpszResourceName); 52 | 53 | protected: 54 | int m_nYPosPix; 55 | int m_nXPosTwips; 56 | int m_nAlignment; 57 | BOOL m_bTrack; 58 | CRulerBar* m_pRuler; 59 | CRect m_rcTrack; 60 | CDC* m_pDC; // dc used for drawing tracking line 61 | int m_nMin, m_nMax; 62 | }; 63 | 64 | class CComboRulerItem : public CRulerItem 65 | { 66 | public: 67 | CComboRulerItem(UINT nBitmapID1, UINT nBitmapID2, CRulerItem& item); 68 | virtual BOOL HitTestPix(CPoint pt); 69 | virtual void Draw(CDC& dc); 70 | virtual void SetHorzPosTwips(int nXPos); 71 | virtual void TrackHorzPosTwips(int nXPos, BOOL bOnRuler = TRUE); 72 | virtual void SetVertPos(int nYPos); 73 | virtual void SetAlignment(int nAlign); 74 | virtual void SetRuler(CRulerBar* pRuler); 75 | virtual void SetBounds(int nMin, int nMax); 76 | int GetMin(); 77 | int GetMax(); 78 | protected: 79 | CRulerItem m_secondary; 80 | CRulerItem& m_link; 81 | BOOL m_bHitPrimary; 82 | }; 83 | 84 | class CTabRulerItem : public CRulerItem 85 | { 86 | public: 87 | CTabRulerItem() { SetAlignment(TA_LEFT); } 88 | virtual void Draw(CDC& dc) {if (GetHorzPosTwips() != 0) CRulerItem::Draw(dc);} 89 | virtual void TrackHorzPosTwips(int nXPos, BOOL bOnRuler = TRUE); 90 | virtual BOOL HitTestPix(CPoint pt) { return (GetHorzPosTwips() != 0) ? CRulerItem::HitTestPix(pt) : FALSE;} 91 | }; 92 | 93 | ///////////////////////////////////////////////////////////////////////////// 94 | // CRulerBar 95 | 96 | class CRulerBar : public CControlBar 97 | { 98 | private: 99 | using CControlBar::Create; 100 | 101 | // Construction 102 | public: 103 | CRulerBar(BOOL b3DExt = TRUE); 104 | ~CRulerBar(); 105 | 106 | // Operations 107 | public: 108 | virtual BOOL Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID); 109 | protected: 110 | void Update(const PARAFORMAT& pf); 111 | void Update(CSize sizePaper, const CRect& rectMargins); 112 | 113 | // Attributes 114 | public: 115 | BOOL m_bDeferInProgress; 116 | BOOL m_bDraw3DExt; 117 | CUnit m_unit; 118 | CRulerItem* m_pSelItem; 119 | CFont fnt; 120 | CSize GetBaseUnits(); 121 | CComboRulerItem m_leftmargin; 122 | CRulerItem m_indent; 123 | CRulerItem m_rightmargin; 124 | CRulerItem m_tabItem; 125 | CTabRulerItem m_pTabItems[MAX_TAB_STOPS]; 126 | CSize m_sizePaper; 127 | CRect m_rectMargin; 128 | int PrintWidth() {return m_sizePaper.cx - m_rectMargin.left - 129 | m_rectMargin.right;} 130 | int m_nTabs; 131 | int m_logx; 132 | int m_nLinePos; 133 | int m_nScroll; // in pixels 134 | 135 | CPen penFocusLine; 136 | CPen penBtnHighLight; 137 | CPen penBtnShadow; 138 | CPen penWindowFrame; 139 | CPen penBtnText; 140 | CPen penBtnFace; 141 | CPen penWindowText; 142 | CPen penWindow; 143 | CBrush brushWindow; 144 | CBrush brushBtnFace; 145 | 146 | // Implementation 147 | public: 148 | virtual void DoPaint(CDC* pDC); 149 | virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz); 150 | void ClientToRuler(CPoint& pt) {pt.Offset(-m_cxLeftBorder+m_nScroll, -m_cyTopBorder);} 151 | void ClientToRuler(CRect& rect) {rect.OffsetRect(-m_cxLeftBorder+m_nScroll, -m_cyTopBorder);} 152 | void RulerToClient(CPoint& pt) {pt.Offset(m_cxLeftBorder-m_nScroll, m_cyTopBorder);} 153 | void RulerToClient(CRect& rect) {rect.OffsetRect(m_cxLeftBorder-m_nScroll, m_cyTopBorder);} 154 | 155 | int XTwipsToClient(int nT) {return MulDiv(nT, m_logx, 1440) + m_cxLeftBorder - m_nScroll;} 156 | int XClientToTwips(int nC) {return MulDiv(nC - m_cxLeftBorder + m_nScroll, 1440, m_logx);} 157 | 158 | int XTwipsToRuler(int nT) {return MulDiv(nT, m_logx, 1440);} 159 | int XRulerToTwips(int nR) {return MulDiv(nR, 1440, m_logx);} 160 | 161 | int XRulerToClient(int nR) {return nR + m_cxLeftBorder - m_nScroll;} 162 | int XClientToRuler(int nC) {return nC - m_cxLeftBorder + m_nScroll;} 163 | 164 | protected: 165 | virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); 166 | void CreateGDIObjects(); 167 | void DrawFace(CDC& dc); 168 | void DrawTickMarks(CDC& dC); 169 | void DrawNumbers(CDC& dc, int nInc, int nTPU); 170 | void DrawDiv(CDC& dc, int nInc, int nLargeDiv, int nLength); 171 | void DrawTabs(CDC& dc); 172 | void FillInParaFormat(PARAFORMAT& pf); 173 | void SortTabs(); 174 | void SetMarginBounds(); 175 | CRulerItem* GetFreeTab(); 176 | CView* GetView() 177 | { 178 | ASSERT(GetParent() != NULL); 179 | return ((CFrameWnd*)GetParent())->GetActiveView(); 180 | } 181 | CDocument* GetDocument() { return GetView()->GetDocument(); } 182 | 183 | CTabRulerItem* GetHitTabPix(CPoint pt); 184 | 185 | // Generated message map functions 186 | //{{AFX_MSG(CRulerBar) 187 | afx_msg void OnLButtonDown(UINT nFlags, CPoint point); 188 | afx_msg void OnLButtonUp(UINT nFlags, CPoint point); 189 | afx_msg void OnMouseMove(UINT nFlags, CPoint point); 190 | afx_msg void OnSysColorChange(); 191 | afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos); 192 | afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); 193 | afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); 194 | //}}AFX_MSG 195 | afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam); 196 | DECLARE_MESSAGE_MAP() 197 | 198 | friend class CRulerItem; 199 | }; 200 | 201 | inline int CRulerItem::GetHorzPosPix() 202 | { return m_pRuler->XTwipsToRuler(m_nXPosTwips); } 203 | 204 | #endif 205 | -------------------------------------------------------------------------------- /splash.cpp: -------------------------------------------------------------------------------- 1 | // splash.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | 15 | #ifdef _DEBUG 16 | #undef THIS_FILE 17 | static char BASED_CODE THIS_FILE[] = __FILE__; 18 | #endif 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | // CSplashWnd dialog 22 | 23 | BOOL CSplashWnd::Create(CWnd* pParent) 24 | { 25 | //{{AFX_DATA_INIT(CSplashWnd) 26 | // NOTE: the ClassWizard will add member initialization here 27 | //}}AFX_DATA_INIT 28 | 29 | if (!CDialog::Create(CSplashWnd::IDD, pParent)) 30 | { 31 | TRACE0("Warning: creation of CSplashWnd dialog failed\n"); 32 | return FALSE; 33 | } 34 | 35 | return TRUE; 36 | } 37 | 38 | BOOL CSplashWnd::OnInitDialog() 39 | { 40 | CDialog::OnInitDialog(); 41 | CenterWindow(); 42 | 43 | // initialize the big icon control 44 | m_icon.SubclassDlgItem(IDC_BIGICON, this); 45 | m_icon.SizeToContent(); 46 | 47 | return TRUE; // return TRUE unless you set the focus to a control 48 | } 49 | 50 | ///////////////////////////////////////////////////////////////////////////// 51 | // CSplashWnd message handlers 52 | 53 | ///////////////////////////////////////////////////////////////////////////// 54 | // CBigIcon 55 | 56 | BEGIN_MESSAGE_MAP(CBigIcon, CButton) 57 | //{{AFX_MSG_MAP(CBigIcon) 58 | ON_WM_DRAWITEM() 59 | ON_WM_ERASEBKGND() 60 | //}}AFX_MSG_MAP 61 | END_MESSAGE_MAP() 62 | 63 | ///////////////////////////////////////////////////////////////////////////// 64 | // CBigIcon message handlers 65 | 66 | #define CY_SHADOW 4 67 | #define CX_SHADOW 4 68 | 69 | void CBigIcon::SizeToContent() 70 | { 71 | m_bitmap.LoadBitmap(IDB_BITMAP48); 72 | BITMAP bm; 73 | m_bitmap.GetObject(sizeof(bm), &bm); 74 | m_sizeBitmap = CSize(bm.bmWidth, bm.bmHeight); 75 | // get system icon size 76 | 77 | // a big icon should be twice the size of an icon + shadows 78 | SetWindowPos(NULL, 0, 0, bm.bmWidth + CX_SHADOW + 4, bm.bmHeight + CY_SHADOW + 4, 79 | SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); 80 | } 81 | 82 | void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 83 | { 84 | CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); 85 | ENSURE(pDC != NULL); 86 | 87 | CRect rect; 88 | GetClientRect(rect); 89 | int cxClient = rect.Width(); 90 | int cyClient = rect.Height(); 91 | 92 | // draw border around icon 93 | CPen pen; 94 | pen.CreateStockObject(BLACK_PEN); 95 | CPen* pPenOld = pDC->SelectObject(&pen); 96 | pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW); 97 | if (pPenOld) 98 | pDC->SelectObject(pPenOld); 99 | 100 | // draw shadows around icon 101 | CBrush br; 102 | br.CreateStockObject(DKGRAY_BRUSH); 103 | rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient); 104 | pDC->FillRect(rect, &br); 105 | rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient); 106 | pDC->FillRect(rect, &br); 107 | 108 | // draw the bitmap contents 109 | CDC dcMem; 110 | if (!dcMem.CreateCompatibleDC(pDC)) 111 | return; 112 | CBitmap* pBitmapOld = dcMem.SelectObject(&m_bitmap); 113 | if (pBitmapOld == NULL) 114 | return; 115 | 116 | pDC->BitBlt(2, 2, m_sizeBitmap.cx, m_sizeBitmap.cy, &dcMem, 0, 0, SRCCOPY); 117 | 118 | dcMem.SelectObject(pBitmapOld); 119 | } 120 | 121 | BOOL CBigIcon::OnEraseBkgnd(CDC*) 122 | { 123 | return TRUE; // we don't do any erasing... 124 | } 125 | 126 | ///////////////////////////////////////////////////////////////////////////// 127 | -------------------------------------------------------------------------------- /splash.h: -------------------------------------------------------------------------------- 1 | // splash.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CBigIcon window 14 | 15 | class CBigIcon : public CButton 16 | { 17 | // Attributes 18 | public: 19 | CBitmap m_bitmap; 20 | CSize m_sizeBitmap; 21 | 22 | // Operations 23 | public: 24 | void SizeToContent(); 25 | 26 | // Implementation 27 | protected: 28 | virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); 29 | 30 | //{{AFX_MSG(CBigIcon) 31 | afx_msg BOOL OnEraseBkgnd(CDC* pDC); 32 | //}}AFX_MSG 33 | DECLARE_MESSAGE_MAP() 34 | }; 35 | 36 | ///////////////////////////////////////////////////////////////////////////// 37 | // CSplash dialog 38 | 39 | #pragma warning(push) 40 | // Disable warning on Create. 41 | #pragma warning(disable : 4264) 42 | #pragma warning(disable : 4263) 43 | class CSplashWnd : public CDialog 44 | { 45 | private: 46 | using CDialog::Create; 47 | 48 | // Construction 49 | public: 50 | BOOL Create(CWnd* pParent = NULL); 51 | 52 | // Dialog Data 53 | //{{AFX_DATA(CSplashWnd) 54 | enum { IDD = IDD_SPLASH }; 55 | // NOTE: the ClassWizard will add data members here 56 | //}}AFX_DATA 57 | 58 | // Implementation 59 | protected: 60 | CBigIcon m_icon; // self-draw button 61 | 62 | // Generated message map functions 63 | //{{AFX_MSG(CSplashWnd) 64 | virtual BOOL OnInitDialog(); 65 | //}}AFX_MSG 66 | }; 67 | #pragma warning(pop) -------------------------------------------------------------------------------- /srvritem.cpp: -------------------------------------------------------------------------------- 1 | // srvritem.cpp : implementation of the CWordPadSrvrItem class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "wordpdoc.h" 15 | #include "wordpvw.h" 16 | #include "srvritem.h" 17 | #include 18 | 19 | IMPLEMENT_DYNAMIC(CEmbeddedItem, COleServerItem) 20 | 21 | extern CLIPFORMAT cfRTF; 22 | 23 | CEmbeddedItem::CEmbeddedItem(CWordPadDoc* pContainerDoc, int nBeg, int nEnd) 24 | : COleServerItem(pContainerDoc, TRUE) 25 | { 26 | ASSERT(pContainerDoc != NULL); 27 | ASSERT_VALID(pContainerDoc); 28 | m_nBeg = nBeg; 29 | m_nEnd = nEnd; 30 | } 31 | 32 | CWordPadView* CEmbeddedItem::GetView() const 33 | { 34 | CDocument* pDoc = GetDocument(); 35 | ASSERT_VALID(pDoc); 36 | POSITION pos = pDoc->GetFirstViewPosition(); 37 | if (pos == NULL) 38 | return NULL; 39 | 40 | CWordPadView* pView = (CWordPadView*)pDoc->GetNextView(pos); 41 | ASSERT_VALID(pView); 42 | ASSERT(pView->IsKindOf(RUNTIME_CLASS(CWordPadView))); 43 | return pView; 44 | } 45 | 46 | void CEmbeddedItem::Serialize(CArchive& ar) 47 | { 48 | if (m_lpRichDataObj != NULL) 49 | { 50 | ASSERT(ar.IsStoring()); 51 | FORMATETC etc = {NULL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL}; 52 | etc.cfFormat = (CLIPFORMAT)cfRTF; 53 | STGMEDIUM stg; 54 | if (SUCCEEDED(m_lpRichDataObj->GetData(&etc, &stg))) 55 | { 56 | LPBYTE p = (LPBYTE)GlobalLock(stg.hGlobal); 57 | if (p != NULL) 58 | { 59 | ar.Write(p, (UINT)GlobalSize(stg.hGlobal)); 60 | GlobalUnlock(stg.hGlobal); 61 | } 62 | ASSERT(stg.tymed == TYMED_HGLOBAL); 63 | ReleaseStgMedium(&stg); 64 | } 65 | } 66 | else 67 | GetDocument()->Serialize(ar); 68 | } 69 | 70 | BOOL CEmbeddedItem::OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize) 71 | { 72 | if (dwDrawAspect != DVASPECT_CONTENT) 73 | return COleServerItem::OnGetExtent(dwDrawAspect, rSize); 74 | 75 | CClientDC dc(NULL); 76 | return OnDrawEx(&dc, rSize, FALSE); 77 | } 78 | 79 | BOOL CEmbeddedItem::OnDraw(CDC* pDC, CSize& rSize) 80 | { 81 | return OnDrawEx(pDC, rSize, TRUE); 82 | } 83 | 84 | BOOL CEmbeddedItem::OnDrawEx(CDC* pDC, CSize& rSize, BOOL bOutput) 85 | { 86 | CDisplayIC dc; 87 | CWordPadView* pView = GetView(); 88 | if (pView == NULL) 89 | return FALSE; 90 | ASSERT_VALID(pView); 91 | 92 | int nWrap = pView->m_nWordWrap; 93 | 94 | CRect rect;//rect in twips 95 | rect.left = rect.top = 0; 96 | rect.bottom = 32767; // bottomless 97 | 98 | rect.right = 32767; 99 | if (nWrap == 0) // no word wrap 100 | rect.right = 32767; 101 | else if (nWrap == 1) // wrap to window 102 | { 103 | CRect rectClient; 104 | pView->GetClientRect(&rectClient); 105 | rect.right = rectClient.right - HORZ_TEXTOFFSET; 106 | rect.right = MulDiv(rect.right, 1440, dc.GetDeviceCaps(LOGPIXELSX)); 107 | } 108 | else if (nWrap == 2) // wrap to ruler 109 | rect.right = pView->GetPrintWidth(); 110 | 111 | // first just determine the correct extents of the text 112 | pDC->SetBkMode(TRANSPARENT); 113 | 114 | if (pView->PrintInsideRect(pDC, rect, m_nBeg, m_nEnd, FALSE) == 0) 115 | { 116 | // default to 12pts high and 4" wide if no text 117 | rect.bottom = rect.top+12*20+1; // 12 pts high 118 | rect.right = rect.left+ 4*1440; 119 | } 120 | rect.bottom+=3*(1440/dc.GetDeviceCaps(LOGPIXELSX)); // three pixels 121 | 122 | // then, really output the text 123 | CRect rectOut = rect; // don't pass rect because it will get clobbered 124 | if (bOutput) 125 | pView->PrintInsideRect(pDC, rectOut, m_nBeg, m_nEnd, TRUE); 126 | ASSERT(rectOut.right == rect.right); 127 | 128 | // adjust for border (rect.left is already adjusted) 129 | if (pView->GetStyle() & WS_HSCROLL) 130 | ++rect.bottom; // account for border on scroll bar! 131 | 132 | // return HIMETRIC size 133 | rSize = rect.Size(); 134 | rSize.cx = MulDiv(rSize.cx, 2540, 1440); // convert twips to HIMETRIC 135 | rSize.cy = MulDiv(rSize.cy, 2540, 1440); // convert twips to HIMETRIC 136 | return TRUE; 137 | } 138 | 139 | ///////////////////////////////////////////////////////////////////////////// 140 | -------------------------------------------------------------------------------- /srvritem.h: -------------------------------------------------------------------------------- 1 | // srvritem.h : interface of the CWordPadSrvrItem class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | class CWordPadDoc; 13 | class CWordPadView; 14 | 15 | class CEmbeddedItem : public COleServerItem 16 | { 17 | public: 18 | using COleServerItem::OnDrawEx; 19 | 20 | DECLARE_DYNAMIC(CEmbeddedItem) 21 | 22 | // Constructors 23 | public: 24 | CEmbeddedItem(CWordPadDoc* pContainerDoc, int nBeg = 0, int nEnd = -1); 25 | 26 | // Attributes 27 | int m_nBeg; 28 | int m_nEnd; 29 | LPDATAOBJECT m_lpRichDataObj; 30 | CWordPadDoc* GetDocument() const 31 | { return (CWordPadDoc*) COleServerItem::GetDocument(); } 32 | CWordPadView* GetView() const; 33 | 34 | // Implementation 35 | public: 36 | BOOL OnDrawEx(CDC* pDC, CSize& rSize, BOOL bOutput); 37 | virtual BOOL OnDraw(CDC* pDC, CSize& rSize); 38 | virtual BOOL OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize); 39 | 40 | protected: 41 | virtual void Serialize(CArchive& ar); // overridden for document i/o 42 | }; 43 | 44 | 45 | ///////////////////////////////////////////////////////////////////////////// 46 | -------------------------------------------------------------------------------- /stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // wordpad.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | // 5 | // This is a part of the Microsoft Foundation Classes C++ library. 6 | // Copyright (c) Microsoft Corporation. All rights reserved. 7 | // 8 | // This source code is only intended as a supplement to the 9 | // Microsoft Foundation Classes Reference and related 10 | // electronic documentation provided with the library. 11 | // See these sources for detailed information regarding the 12 | // Microsoft Foundation Classes product. 13 | 14 | #include "stdafx.h" 15 | -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | // 6 | // This is a part of the Microsoft Foundation Classes C++ library. 7 | // Copyright (c) Microsoft Corporation. All rights reserved. 8 | // 9 | // This source code is only intended as a supplement to the 10 | // Microsoft Foundation Classes Reference and related 11 | // electronic documentation provided with the library. 12 | // See these sources for detailed information regarding the 13 | // Microsoft Foundation Classes product. 14 | 15 | #ifndef _UNICODE 16 | #define VC_EXTRALEAN // use stripped down Win32 headers 17 | #endif 18 | 19 | #include "targetver.h" 20 | 21 | #define CONVERTERS 22 | 23 | #include // MFC core and standard components 24 | #include // MFC extensions 25 | #include // MFC OLE classes 26 | #include // MFC OLE dialog classes 27 | #include 28 | #include 29 | #include 30 | 31 | #define HORZ_TEXTOFFSET 15 32 | #define VERT_TEXTOFFSET 5 33 | 34 | class CDisplayIC : public CDC 35 | { 36 | public: 37 | CDisplayIC() { CreateIC(_T("DISPLAY"), NULL, NULL, NULL); } 38 | }; 39 | 40 | struct CCharFormat : public CHARFORMAT2 41 | { 42 | CCharFormat() {cbSize = sizeof(CHARFORMAT2);} 43 | BOOL operator==(CCharFormat& cf); 44 | }; 45 | 46 | struct CParaFormat : public PARAFORMAT2 47 | { 48 | CParaFormat() {cbSize = sizeof(_paraformat);} 49 | BOOL operator==(PARAFORMAT2& pf); 50 | }; 51 | 52 | #include "doctype.h" 53 | #include "chicdial.h" 54 | 55 | #ifndef _AFX_NO_OLE_SUPPORT 56 | #include // MFC support for Internet Explorer 4 Common Controls 57 | #endif 58 | #ifndef _AFX_NO_AFXCMN_SUPPORT 59 | #include // MFC support for Windows Common Controls 60 | #endif // _AFX_NO_AFXCMN_SUPPORT 61 | 62 | #include // MFC ribbon and control bar support 63 | 64 | #if defined _M_IX86 65 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"") 66 | #elif defined _M_X64 67 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"") 68 | #else 69 | #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") 70 | #endif -------------------------------------------------------------------------------- /strings.cpp: -------------------------------------------------------------------------------- 1 | // strings.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "strings.h" 14 | 15 | #ifdef _DEBUG 16 | #undef THIS_FILE 17 | static char BASED_CODE THIS_FILE[] = __FILE__; 18 | #endif 19 | 20 | const TCHAR szWordPadClass[] = _T("WordPadClass"); 21 | const TCHAR szLayout1[] = _T("Layout2"); 22 | const TCHAR szLayout2[] = _T("LayoutAux2"); 23 | const TCHAR szRegKey[] = _T("Microsoft\\Windows\\CurrentVersion\\Applets"); 24 | 25 | const TCHAR szTextSection[] = _T("Text"); 26 | const TCHAR szRTFSection[] = _T("RTF"); 27 | const TCHAR szWordSection[] = _T("Word6"); 28 | const TCHAR szWriteSection[] =_T("Write"); 29 | const TCHAR szIPSection[] = _T("IP"); 30 | const TCHAR szWrap[] = _T("Wrap"); 31 | const TCHAR szPageMargin[] = _T("PageMargin"); 32 | 33 | const TCHAR szSection[] = _T("Options"); 34 | const TCHAR szWordSel[] = _T("WordSel"); 35 | const TCHAR szUnits[] = _T("Units"); 36 | const TCHAR szFrameRect[] = _T("FrameRect"); 37 | const TCHAR szMaximized[] = _T("Maximized"); 38 | 39 | const TCHAR szSumInfo[] = _T("\005SummaryInformation"); 40 | 41 | const char szWordConverter[] = "MSWRD632.WPC"; 42 | const char szWriteConverter[] = "WRITE32.WPC"; 43 | 44 | const TCHAR szContents[] = _T("Contents"); 45 | -------------------------------------------------------------------------------- /strings.h: -------------------------------------------------------------------------------- 1 | // strings.h : defines all extern const strings 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #ifndef __AFXWIN_H__ 13 | #error include 'stdafx.h' before including this file for PCH 14 | #endif 15 | 16 | extern const TCHAR szWordPadClass[]; 17 | extern const TCHAR szLayout1[]; 18 | extern const TCHAR szLayout2[]; 19 | extern const TCHAR szRegKey[]; 20 | 21 | extern const TCHAR szTextSection[]; 22 | extern const TCHAR szRTFSection[]; 23 | extern const TCHAR szWordSection[]; 24 | extern const TCHAR szWriteSection[]; 25 | extern const TCHAR szIPSection[]; 26 | extern const TCHAR szWrap[]; 27 | extern const TCHAR szPageMargin[]; 28 | 29 | extern const TCHAR szSection[]; 30 | extern const TCHAR szWordSel[]; 31 | extern const TCHAR szUnits[]; 32 | extern const TCHAR szFrameRect[]; 33 | extern const TCHAR szMaximized[]; 34 | extern const TCHAR szDeleteTemp[]; 35 | 36 | extern const TCHAR szSumInfo[]; 37 | 38 | extern const char szWordConverter[]; 39 | extern const char szWriteConverter[]; 40 | 41 | extern const TCHAR szContents[]; 42 | -------------------------------------------------------------------------------- /targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifndef _WIN32_WINNT 6 | // Modify the following define to target a prior platform. Refer to MSDN 7 | // for the latest info on corresponding values for different platforms. 8 | #define _WIN32_WINNT _WIN32_WINNT_MAXVER 9 | #endif 10 | 11 | #include -------------------------------------------------------------------------------- /unitspag.cpp: -------------------------------------------------------------------------------- 1 | // unitspag.cpp : implementation file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #include "stdafx.h" 13 | #include "wordpad.h" 14 | #include "unitspag.h" 15 | #include "helpids.h" 16 | 17 | #ifdef _DEBUG 18 | #undef THIS_FILE 19 | static char BASED_CODE THIS_FILE[] = __FILE__; 20 | #endif 21 | 22 | ///////////////////////////////////////////////////////////////////////////// 23 | // CUnitsPage dialog 24 | 25 | const DWORD CUnitsPage::m_nHelpIDs[] = 26 | { 27 | IDC_BOX, IDH_COMM_GROUPBOX, 28 | IDC_UNITS_IN, IDH_WORDPAD_INCHES, 29 | IDC_UNITS_CM, IDH_WORDPAD_CENTIMETERS, 30 | IDC_UNITS_PT, IDH_WORDPAD_POINTS, 31 | IDC_UNITS_PI, IDH_WORDPAD_PICAS, 32 | IDC_WORDSEL, IDH_WORDPAD_OPTIONS_AUTOWORDSEL, 33 | 0, 0 34 | }; 35 | 36 | CUnitsPage::CUnitsPage() : CCSPropertyPage(CUnitsPage::IDD) 37 | { 38 | //{{AFX_DATA_INIT(CUnitsPage) 39 | m_nUnits = -1; 40 | m_bWordSel = FALSE; 41 | //}}AFX_DATA_INIT 42 | } 43 | 44 | 45 | void CUnitsPage::DoDataExchange(CDataExchange* pDX) 46 | { 47 | CCSPropertyPage::DoDataExchange(pDX); 48 | //{{AFX_DATA_MAP(CUnitsPage) 49 | DDX_Radio(pDX, IDC_UNITS_IN, m_nUnits); 50 | DDX_Check(pDX, IDC_WORDSEL, m_bWordSel); 51 | //}}AFX_DATA_MAP 52 | } 53 | 54 | BEGIN_MESSAGE_MAP(CUnitsPage, CCSPropertyPage) 55 | //{{AFX_MSG_MAP(CUnitsPage) 56 | // NOTE: the ClassWizard will add message map macros here 57 | //}}AFX_MSG_MAP 58 | END_MESSAGE_MAP() 59 | 60 | 61 | ///////////////////////////////////////////////////////////////////////////// 62 | // CUnitsPage message handlers 63 | -------------------------------------------------------------------------------- /unitspag.h: -------------------------------------------------------------------------------- 1 | // unitspag.h : header file 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // CUnitsPage dialog 14 | 15 | class CUnitsPage : public CCSPropertyPage 16 | { 17 | // Construction 18 | public: 19 | CUnitsPage(); // standard constructor 20 | 21 | // Dialog Data 22 | //{{AFX_DATA(CUnitsPage) 23 | enum { IDD = IDD_OPTIONS_UNITS }; 24 | int m_nUnits; 25 | BOOL m_bWordSel; 26 | //}}AFX_DATA 27 | 28 | 29 | // Overrides 30 | // ClassWizard generated virtual function overrides 31 | //{{AFX_VIRTUAL(CUnitsPage) 32 | protected: 33 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 34 | //}}AFX_VIRTUAL 35 | 36 | // Implementation 37 | protected: 38 | static const DWORD m_nHelpIDs[]; 39 | virtual const DWORD* GetHelpIDs() {return m_nHelpIDs;} 40 | 41 | // Generated message map functions 42 | //{{AFX_MSG(CUnitsPage) 43 | // NOTE: the ClassWizard will add member functions here 44 | //}}AFX_MSG 45 | DECLARE_MESSAGE_MAP() 46 | }; 47 | -------------------------------------------------------------------------------- /wordpad.h: -------------------------------------------------------------------------------- 1 | // wordpad.h : main header file for the WORDPAD application 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | #ifndef __AFXWIN_H__ 13 | #error include 'stdafx.h' before including this file for PCH 14 | #endif 15 | 16 | #include "resource.h" // main symbols 17 | #include "splash.h" 18 | #include "options.h" 19 | #include "afxtempl.h" 20 | 21 | #define WPM_BARSTATE WM_USER 22 | 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // CWordPadApp: 25 | // See wordpad.cpp for the implementation of this class 26 | // 27 | 28 | class CWordPadCommandLineInfo : public CCommandLineInfo 29 | { 30 | public: 31 | CWordPadCommandLineInfo() {m_bForceTextMode = FALSE;} 32 | BOOL m_bForceTextMode; 33 | virtual void ParseParam(const char* pszParam,BOOL bFlag,BOOL bLast); 34 | }; 35 | 36 | class CWordPadApp : public CWinApp 37 | { 38 | public: 39 | CWordPadApp(); 40 | ~CWordPadApp(); 41 | 42 | //Attributes 43 | CWordPadCommandLineInfo cmdInfo; 44 | CDC m_dcScreen; 45 | LOGFONT m_lf; 46 | int m_nDefFont; 47 | static int m_nOpenMsg; 48 | static int m_nPrinterChangedMsg; 49 | CRect m_rectPageMargin; 50 | CRect m_rectInitialFrame; 51 | BOOL m_bMaximized; 52 | BOOL m_bPromptForType; 53 | BOOL m_bWin4; 54 | #ifndef _UNICODE 55 | BOOL m_bWin31; 56 | #endif 57 | BOOL m_bLargeIcons; 58 | BOOL m_bForceTextMode; 59 | BOOL m_bWordSel; 60 | BOOL m_bForceOEM; 61 | int m_nFilterIndex; 62 | int m_nNewDocType; 63 | CDocOptions m_optionsText; 64 | CDocOptions m_optionsRTF; 65 | CDocOptions m_optionsWord; //wrap to ruler 66 | CDocOptions m_optionsWrite; //wrap to ruler 67 | CDocOptions m_optionsIP; //wrap to ruler 68 | CDocOptions m_optionsNull; 69 | CList m_listPrinterNotify; 70 | 71 | BOOL IsDocOpen(LPCTSTR lpszFileName); 72 | 73 | // Get 74 | int GetUnits() {return m_nUnits;} 75 | int GetTPU() { return GetTPU(m_nUnits);} 76 | int GetTPU(int n) { return m_units[n].m_nTPU;} 77 | LPCTSTR GetAbbrev() { return m_units[m_nUnits].m_strAbbrev;} 78 | LPCTSTR GetAbbrev(int n) { return m_units[n].m_strAbbrev;} 79 | const CUnit& GetUnit() {return m_units[m_nUnits];} 80 | CDockState& GetDockState(LONG_PTR nDocType, BOOL bPrimary = TRUE); 81 | CDocOptions& GetDocOptions(LONG_PTR nDocType); 82 | 83 | // Set 84 | void SetUnits(int n) 85 | { ASSERT(n>=0 && n 2 | 3 | 4 | 5 | {aa570413-2155-455e-b8a5-95cb2cc75bb4} 6 | h;hpp;hxx;inl;fi;fd 7 | 8 | 9 | {43d29fb7-a2b5-4299-b623-1c4f8b0d2dd3} 10 | rc;ico;cur;bmp;dlg;rc2;rct;cnt;rtf;gif;jpg;jpeg;jpe 11 | 12 | 13 | {982a2bcf-72c9-4011-bd10-68da7d32deeb} 14 | cpp;c;cxx;def;r;odl;hpj;bat;for;f90 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | Source Files 68 | 69 | 70 | Source Files 71 | 72 | 73 | Source Files 74 | 75 | 76 | Source Files 77 | 78 | 79 | Source Files 80 | 81 | 82 | Source Files 83 | 84 | 85 | Source Files 86 | 87 | 88 | Source Files 89 | 90 | 91 | Source Files 92 | 93 | 94 | Source Files 95 | 96 | 97 | Source Files 98 | 99 | 100 | Source Files 101 | 102 | 103 | Source Files 104 | 105 | 106 | 107 | 108 | Resource Files 109 | 110 | 111 | 112 | 113 | Header Files 114 | 115 | 116 | Header Files 117 | 118 | 119 | Header Files 120 | 121 | 122 | Header Files 123 | 124 | 125 | Header Files 126 | 127 | 128 | Header Files 129 | 130 | 131 | Header Files 132 | 133 | 134 | Header Files 135 | 136 | 137 | Header Files 138 | 139 | 140 | Header Files 141 | 142 | 143 | Header Files 144 | 145 | 146 | Header Files 147 | 148 | 149 | Header Files 150 | 151 | 152 | Header Files 153 | 154 | 155 | Header Files 156 | 157 | 158 | Header Files 159 | 160 | 161 | Header Files 162 | 163 | 164 | Header Files 165 | 166 | 167 | Header Files 168 | 169 | 170 | Header Files 171 | 172 | 173 | Header Files 174 | 175 | 176 | Header Files 177 | 178 | 179 | Resource Files 180 | 181 | 182 | Resource Files 183 | 184 | 185 | Resource Files 186 | 187 | 188 | Resource Files 189 | 190 | 191 | Resource Files 192 | 193 | 194 | Resource Files 195 | 196 | 197 | Resource Files 198 | 199 | 200 | Resource Files 201 | 202 | 203 | Resource Files 204 | 205 | 206 | Resource Files 207 | 208 | 209 | Resource Files 210 | 211 | 212 | Resource Files 213 | 214 | 215 | Resource Files 216 | 217 | 218 | Resource Files 219 | 220 | 221 | Resource Files 222 | 223 | 224 | Resource Files 225 | 226 | 227 | Resource Files 228 | 229 | 230 | Resource Files 231 | 232 | 233 | Resource Files 234 | 235 | 236 | Resource Files 237 | 238 | 239 | Resource Files 240 | 241 | 242 | Header Files 243 | 244 | 245 | Header Files 246 | 247 | 248 | Header Files 249 | 250 | 251 | Header Files 252 | 253 | 254 | Header Files 255 | 256 | 257 | Header Files 258 | 259 | 260 | Header Files 261 | 262 | 263 | Header Files 264 | 265 | 266 | Header Files 267 | 268 | 269 | 270 | 271 | Header Files 272 | 273 | 274 | -------------------------------------------------------------------------------- /wordpdoc.h: -------------------------------------------------------------------------------- 1 | // wordpdoc.h : interface of the CWordPadDoc class 2 | // 3 | // This is a part of the Microsoft Foundation Classes C++ library. 4 | // Copyright (c) Microsoft Corporation. All rights reserved. 5 | // 6 | // This source code is only intended as a supplement to the 7 | // Microsoft Foundation Classes Reference and related 8 | // electronic documentation provided with the library. 9 | // See these sources for detailed information regarding the 10 | // Microsoft Foundation Classes product. 11 | 12 | class CFormatBar; 13 | class CWordPadSrvrItem; 14 | class CWordPadView; 15 | 16 | class CWordPadDoc : public CRichEditDoc 17 | { 18 | private: 19 | using CRichEditDoc::GetView; 20 | 21 | protected: // create from serialization only 22 | CWordPadDoc(); 23 | DECLARE_DYNCREATE(CWordPadDoc) 24 | 25 | // Attributes 26 | public: 27 | int m_nDocType; 28 | int m_nNewDocType; 29 | void SetDocType(int nDocType, BOOL bNoOptionChange = FALSE); 30 | CWordPadView* GetView(); 31 | CLSID GetClassID(); 32 | LPCTSTR GetSection(); 33 | 34 | // Operations 35 | public: 36 | void SaveState(int nType); 37 | void RestoreState(int nType); 38 | virtual CFile* GetFile(LPCTSTR pszPathName, UINT nOpenFlags, 39 | CFileException* pException); 40 | virtual BOOL DoSave(LPCTSTR pszPathName, BOOL bReplace = TRUE); 41 | int MapType(int nType); 42 | void ForceDelayed(CFrameWnd* pFrameWnd); 43 | 44 | // Overrides 45 | virtual CRichEditCntrItem* CreateClientItem(REOBJECT* preo) const; 46 | virtual void OnDeactivateUI(BOOL bUndoable); 47 | virtual void Serialize(CArchive& ar); 48 | // ClassWizard generated virtual function overrides 49 | //{{AFX_VIRTUAL(CWordPadDoc) 50 | public: 51 | virtual BOOL OnNewDocument(); 52 | virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); 53 | virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo); 54 | virtual void OnCloseDocument(); 55 | virtual void ReportSaveLoadException(LPCTSTR lpszPathName, CException* e, BOOL bSaving, UINT nIDPDefault); 56 | protected: 57 | virtual COleServerItem* OnGetEmbeddedItem(); 58 | //}}AFX_VIRTUAL 59 | 60 | // Implementation 61 | public: 62 | virtual void PreCloseFrame(CFrameWnd* pFrameArg); 63 | #ifdef _DEBUG 64 | virtual void AssertValid() const; 65 | virtual void Dump(CDumpContext& dc) const; 66 | #endif 67 | 68 | // Generated message map functions 69 | protected: 70 | //{{AFX_MSG(CWordPadDoc) 71 | afx_msg void OnViewOptions(); 72 | afx_msg void OnUpdateOleVerbPopup(CCmdUI* pCmdUI); 73 | afx_msg void OnFileSendMail(); 74 | afx_msg void OnUpdateIfEmbedded(CCmdUI* pCmdUI); 75 | //}}AFX_MSG 76 | DECLARE_MESSAGE_MAP() 77 | }; 78 | 79 | ///////////////////////////////////////////////////////////////////////////// 80 | -------------------------------------------------------------------------------- /wordpvw.h: -------------------------------------------------------------------------------- 1 | // wordpvw.h : interface of the CWordPadView class 2 | // 3 | // 4 | // This is a part of the Microsoft Foundation Classes C++ library. 5 | // Copyright (c) Microsoft Corporation. All rights reserved. 6 | // 7 | // This source code is only intended as a supplement to the 8 | // Microsoft Foundation Classes Reference and related 9 | // electronic documentation provided with the library. 10 | // See these sources for detailed information regarding the 11 | // Microsoft Foundation Classes product. 12 | 13 | class CWordPadView : public CRichEditView 14 | { 15 | protected: // create from serialization only 16 | CWordPadView(); 17 | DECLARE_DYNCREATE(CWordPadView) 18 | 19 | // Attributes 20 | public: 21 | UINT_PTR m_uTimerID; 22 | BOOL m_bDelayUpdateItems; 23 | BOOL m_bInPrint; 24 | CParaFormat m_defParaFormat; 25 | CCharFormat m_defCharFormat; 26 | CCharFormat m_defTextCharFormat; 27 | 28 | CWordPadDoc* GetDocument(); 29 | BOOL IsFormatText(); 30 | 31 | virtual HMENU GetContextMenu(WORD seltype, LPOLEOBJECT lpoleobj, 32 | CHARRANGE* lpchrg); 33 | 34 | // Operations 35 | public: 36 | BOOL PasteNative(LPDATAOBJECT lpdataobj); 37 | void SetDefaultFont(BOOL bText); 38 | void SetUpdateTimer(); 39 | void GetDefaultFont(CCharFormat& cf, UINT nFontNameID); 40 | void DrawMargins(CDC* pDC); 41 | BOOL SelectPalette(); 42 | 43 | // Overrides 44 | // ClassWizard generated virtual function overrides 45 | //{{AFX_VIRTUAL(CWordPadView) 46 | protected: 47 | virtual void CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType = adjustBorder); 48 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 49 | virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); 50 | //}}AFX_VIRTUAL 51 | BOOL OnPreparePrinting(CPrintInfo* pInfo); 52 | virtual HRESULT GetClipboardData(CHARRANGE* lpchrg, DWORD reco, 53 | LPDATAOBJECT lpRichDataObj, LPDATAOBJECT* lplpdataobj); 54 | virtual HRESULT QueryAcceptData(LPDATAOBJECT, CLIPFORMAT*, DWORD, 55 | BOOL, HGLOBAL); 56 | public: 57 | virtual void WrapChanged(); 58 | 59 | // Implementation 60 | public: 61 | #ifdef _DEBUG 62 | virtual void AssertValid() const; 63 | virtual void Dump(CDumpContext& dc) const; 64 | #endif 65 | 66 | protected: 67 | BOOL m_bOnBar; 68 | 69 | // OLE Container support 70 | 71 | virtual void DeleteContents(); 72 | virtual void OnTextNotFound(LPCTSTR); 73 | 74 | // Generated message map functions 75 | protected: 76 | afx_msg void OnCancelEditSrvr(); 77 | //{{AFX_MSG(CWordPadView) 78 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 79 | afx_msg void OnPageSetup(); 80 | afx_msg void OnInsertDateTime(); 81 | afx_msg void OnFormatParagraph(); 82 | afx_msg void OnFormatTabs(); 83 | afx_msg void OnTimer(UINT_PTR nIDEvent); 84 | afx_msg void OnDestroy(); 85 | afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct); 86 | afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); 87 | afx_msg void OnFilePrint(); 88 | afx_msg void OnPaletteChanged(CWnd* pFocusWnd); 89 | afx_msg BOOL OnQueryNewPalette(); 90 | afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection); 91 | afx_msg void OnSize(UINT nType, int cx, int cy); 92 | //}}AFX_MSG 93 | afx_msg void OnEditChange(); 94 | afx_msg void OnColorPick(UINT nID); 95 | afx_msg int OnMouseActivate(CWnd* pWnd, UINT nHitTest, UINT message); 96 | afx_msg LONG_PTR OnPrinterChangedMsg(UINT_PTR, LONG_PTR); 97 | afx_msg void OnGetCharFormat(NMHDR* pNMHDR, LRESULT* pRes); 98 | afx_msg void OnSetCharFormat(NMHDR* pNMHDR, LRESULT* pRes); 99 | afx_msg void OnBarSetFocus(NMHDR*, LRESULT*); 100 | afx_msg void OnBarKillFocus(NMHDR*, LRESULT*); 101 | afx_msg void OnBarReturn(NMHDR*, LRESULT* ); 102 | DECLARE_MESSAGE_MAP() 103 | }; 104 | 105 | #ifndef _DEBUG // debug version in wordpvw.cpp 106 | inline CWordPadDoc* CWordPadView::GetDocument() 107 | { return (CWordPadDoc*)m_pDocument; } 108 | #endif 109 | 110 | ///////////////////////////////////////////////////////////////////////////// 111 | -------------------------------------------------------------------------------- /write32.wpc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pmachapman/WordPad/7c51cca1396d792bfcdeb9d2907af15789b89b3a/write32.wpc --------------------------------------------------------------------------------