├── .gitignore ├── README.md ├── license.txt ├── pkg ├── Makefile ├── bld-pkglist.ys1 ├── bld.ys1 ├── wordpad-pdb.lst └── wordpad.lst └── src ├── about.cpp ├── about.h ├── bigicon.cpp ├── bigicon.h ├── 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 ├── listdlg.cpp ├── listdlg.h ├── mainfrm.cpp ├── mainfrm.h ├── makefile ├── mswd6_32.h ├── 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 ├── unitspag.cpp ├── unitspag.h ├── wordpad.cpp ├── wordpad.h ├── wordpad.manifest ├── wordpad.rc ├── wordpdoc.cpp ├── wordpdoc.h ├── wordpvw.cpp ├── wordpvw.h └── write32.wpc /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.cab 2 | **/*.exe 3 | **/*.exp 4 | **/*.lib 5 | **/*.obj 6 | **/*.pdb 7 | **/*.pch 8 | **/*.pru 9 | **/*.res 10 | pkg/out/** 11 | src/Release/** 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WordPad 2 | 3 | This repo is an attempt to maintain the WordPad source code and keep it useful and relevant. 4 | 5 | ## Building 6 | 7 | To compile, you'll need Visual C++ 2005 or newer. Make sure you have MFC support installed. Compile by running NMAKE (or YMAKE for parallel compilation.) 8 | 9 | ## Contributing 10 | 11 | Please keep contributions in the style and spirit of the existing code, and ensure changes build on Visual C++ 2005 or newer. 12 | 13 | ## License 14 | 15 | This code is available under the same license as the sample code, MIT + All rights reserved. 16 | 17 | ## History 18 | 19 | The WordPad source code has been included as a sample in compilers since 1995 under restrictive terms. These samples are now available under the MIT license, including the version bundled with Visual C++ 2008 and 2010. This source is a fork of the [most recent code from the 2010 compiler](https://github.com/microsoft/VCSamples/tree/master/VC2010Samples/MFC/ole/wordpad). 20 | 21 | ## Changes 22 | 23 | - Add MIT license to compiled binaries, which is required by the license 24 | - Compile only for Unicode 25 | - Uses RichEdit 2.0 rather than 1.0 26 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | VCSamples 2 | Copyright (c) Microsoft Corporation 3 | 4 | All rights reserved. 5 | 6 | MIT License 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | this software and associated documentation files (the "Software"), to deal in 10 | the Software without restriction, including without limitation the rights to 11 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 | of the Software, and to permit persons to whom the Software is furnished to do 13 | so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in all 16 | copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | -------------------------------------------------------------------------------- /pkg/Makefile: -------------------------------------------------------------------------------- 1 | !IFDEF _YMAKE_VER 2 | 3 | set VERSION= 4 | 5 | ARCH=win32 6 | 7 | !IF [$(CC) -? 2>&1 | findstr /C:"x64" >NUL 2>&1]==0 8 | ARCH=amd64 9 | !ELSE 10 | !IF [$(CC) -? 2>&1 | findstr /C:"AMD64" >NUL 2>&1]==0 11 | ARCH=amd64 12 | !ELSE 13 | !IF [$(CC) -? 2>&1 | findstr /C:"ARM64" >NUL 2>&1]==0 14 | ARCH=arm64 15 | !ELSE 16 | !IF [$(CC) -? 2>&1 | findstr /C:"ARM" >NUL 2>&1]==0 17 | ARCH=arm 18 | !ELSE 19 | !IF [$(CC) -? 2>&1 | findstr /C:"Itanium" >NUL 2>&1]==0 20 | ARCH=ia64 21 | !ELSE 22 | !IF [$(CC) -? 2>&1 | findstr /C:"MIPS" >NUL 2>&1]==0 23 | ARCH=mips 24 | !ENDIF # MIPS 25 | !ENDIF # Itanium 26 | !ENDIF # ARM (32) 27 | !ENDIF # ARM64 28 | !ENDIF # AMD64 29 | !ENDIF # x64 30 | 31 | URLROOT=http://www.malsmith.net/download/?obj=wordpad/latest-stable 32 | 33 | ARCHPKGS=out\wordpad-$(ARCH).cab \ 34 | out\wordpad-pdb-$(ARCH).cab 35 | 36 | NOARCHPKGS=out\wordpad-source.cab 37 | 38 | all: $(ARCHPKGS) $(NOARCHPKGS) 39 | 40 | out: 41 | @echo $(@F) 42 | @mkdir out 43 | 44 | out\wordpad-$(ARCH).cab: out wordpad.lst 45 | @echo $(@F) 46 | @ypm -c out\wordpad-$(ARCH).cab wordpad $(VERSION) $(ARCH) -filelist wordpad.lst -minimumosbuild 1381 -upgradepath $(URLROOT)/wordpad-$(ARCH).cab -symbolpath $(URLROOT)/wordpad-pdb-$(ARCH).cab -sourcepath $(URLROOT)/wordpad-source.cab 47 | 48 | out\wordpad-pdb-$(ARCH).cab: out wordpad-pdb.lst 49 | @echo $(@F) 50 | @ypm -c out\wordpad-pdb-$(ARCH).cab wordpad-pdb $(VERSION) $(ARCH) -filelist wordpad-pdb.lst -upgradepath $(URLROOT)/wordpad-pdb-$(ARCH).cab -sourcepath $(URLROOT)/wordpad-source.cab 51 | 52 | out\wordpad-source.cab: 53 | @echo $(@F) 54 | @ypm -cs out\wordpad-source.cab wordpad-source $(VERSION) -filepath .. 55 | 56 | !ENDIF 57 | -------------------------------------------------------------------------------- /pkg/bld-pkglist.ys1: -------------------------------------------------------------------------------- 1 | setlocal 2 | set PKGNAME=%1% 3 | set PKGARCH=%2% 4 | set VERSION=%3% 5 | initool -w out\pkglist.ini Provides %PKGNAME% %VERSION% 6 | initool -w out\pkglist.ini %PKGNAME% Version %VERSION% 7 | initool -w out\pkglist.ini %PKGNAME% %PKGARCH% %PKGNAME%-%PKGARCH%.cab 8 | endlocal 9 | -------------------------------------------------------------------------------- /pkg/bld.ys1: -------------------------------------------------------------------------------- 1 | setlocal 2 | 3 | REM 4 | REM Determine architecture by looking at compiler output. 5 | REM 6 | 7 | set ARCH=win32 8 | cl /? 2>&1 | findstr /C:"for x64" >NUL 2>&1 9 | if intcmp %ERRORLEVEL%==0;set ARCH=amd64 10 | cl /? 2>&1 | findstr /C:"for AMD64" >NUL 2>&1 11 | if intcmp %ERRORLEVEL%==0;set ARCH=amd64 12 | cl /? 2>&1 | findstr /C:"for ARM" >NUL 2>&1 13 | if intcmp %ERRORLEVEL%==0;set ARCH=arm 14 | cl /? 2>&1 | findstr /C:"for ARM64" >NUL 2>&1 15 | if intcmp %ERRORLEVEL%==0;set ARCH=arm64 16 | cl /? 2>&1 | findstr /C:"for MIPS" >NUL 2>&1 17 | if intcmp %ERRORLEVEL%==0;set ARCH=mips 18 | cl /? 2>&1 | findstr /C:"for Itanium" >NUL 2>&1 19 | if intcmp %ERRORLEVEL%==0;set ARCH=ia64 20 | 21 | REM 22 | REM Set build ID. 23 | REM 24 | 25 | set VERSION=`date` 26 | 27 | echo *** Cleaning tree 28 | pushd ..\src 29 | ymake clean >NUL 30 | popd 31 | 32 | echo *** Building %ARCH% retail 33 | ymake -f ..\src\Makefile -m 34 | if intcmp %ERRORLEVEL%!=0; goto exit 35 | 36 | echo *** Packaging %ARCH% retail 37 | ymake -f Makefile VERSION=%VERSION% 38 | 39 | REM 40 | REM Generate pkglist.ini so that tools can find packages provided by this 41 | REM directory 42 | REM 43 | 44 | bld-pkglist wordpad %ARCH% %VERSION% 45 | bld-pkglist wordpad-pdb %ARCH% %VERSION% 46 | bld-pkglist wordpad-source noarch %VERSION% 47 | 48 | :exit 49 | 50 | endlocal 51 | -------------------------------------------------------------------------------- /pkg/wordpad-pdb.lst: -------------------------------------------------------------------------------- 1 | ..\src\Release\wordpad.pdb|wordpad.pdb 2 | -------------------------------------------------------------------------------- /pkg/wordpad.lst: -------------------------------------------------------------------------------- 1 | ..\src\Release\wordpad.exe|wordpad.exe 2 | -------------------------------------------------------------------------------- /src/about.cpp: -------------------------------------------------------------------------------- 1 | // about.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 | // CAboutDialog dialog 22 | 23 | CAboutDialog::CAboutDialog(CWnd* pParent /*=NULL*/) 24 | : CDialog(CAboutDialog::IDD, pParent) 25 | { 26 | //{{AFX_DATA_INIT(CAboutDialog) 27 | //}}AFX_DATA_INIT 28 | } 29 | 30 | BOOL CAboutDialog::OnInitDialog() 31 | { 32 | CDialog::OnInitDialog(); 33 | CenterWindow(); 34 | 35 | // initialize the big icon control 36 | m_icon.SubclassDlgItem(IDC_BIGICON, this); 37 | m_icon.SizeToContent(); 38 | 39 | HINSTANCE hInst = AfxGetInstanceHandle(); 40 | 41 | HRSRC hRsrc = ::FindResource(hInst, MAKEINTRESOURCE(IDR_LICENSE_TEXT), RT_RCDATA); 42 | if (hRsrc == NULL) 43 | return FALSE; 44 | 45 | HGLOBAL hLoadedRsrc = ::LoadResource(hInst, hRsrc); 46 | if (hLoadedRsrc == NULL) 47 | return FALSE; 48 | 49 | DWORD ResourceSize = ::SizeofResource(hInst, hRsrc); 50 | 51 | LPCSTR LicenseTextPtr = (LPCSTR)::LockResource(hLoadedRsrc); 52 | 53 | if (LicenseTextPtr == NULL) 54 | return FALSE; 55 | 56 | CString LicenseText(LicenseTextPtr, ResourceSize); 57 | 58 | CEdit* pEditBox = (CEdit*)GetDlgItem(IDC_LICENSE_TEXT); 59 | pEditBox->SetWindowText(LicenseText); 60 | 61 | return FALSE; // return TRUE unless you set the focus to a control 62 | } 63 | 64 | -------------------------------------------------------------------------------- /src/about.h: -------------------------------------------------------------------------------- 1 | // about.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 | // CAbout dialog 14 | 15 | #pragma warning(push) 16 | // Disable warning on Create. 17 | #pragma warning(disable : 4264) 18 | #pragma warning(disable : 4263) 19 | class CAboutDialog : public CDialog 20 | { 21 | private: 22 | using CDialog::Create; 23 | 24 | // Construction 25 | public: 26 | CAboutDialog(CWnd* pParent = NULL); // standard constructor 27 | 28 | // Dialog Data 29 | //{{AFX_DATA(CAboutDialog) 30 | enum { IDD = IDD_ABOUT }; 31 | // NOTE: the ClassWizard will add data members here 32 | //}}AFX_DATA 33 | 34 | // Implementation 35 | protected: 36 | CBigIcon m_icon; // self-draw button 37 | 38 | // Generated message map functions 39 | //{{AFX_MSG(CAboutDialog) 40 | virtual BOOL OnInitDialog(); 41 | afx_msg UINT OnGetDlgCode(); 42 | //}}AFX_MSG 43 | }; 44 | #pragma warning(pop) 45 | -------------------------------------------------------------------------------- /src/bigicon.cpp: -------------------------------------------------------------------------------- 1 | // bigicon.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 | // CBigIcon 22 | 23 | BEGIN_MESSAGE_MAP(CBigIcon, CButton) 24 | //{{AFX_MSG_MAP(CBigIcon) 25 | ON_WM_DRAWITEM() 26 | ON_WM_ERASEBKGND() 27 | //}}AFX_MSG_MAP 28 | END_MESSAGE_MAP() 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | // CBigIcon message handlers 32 | 33 | #define CY_SHADOW 4 34 | #define CX_SHADOW 4 35 | 36 | void CBigIcon::SizeToContent() 37 | { 38 | m_bitmap.LoadBitmap(IDB_BITMAP48); 39 | BITMAP bm; 40 | m_bitmap.GetObject(sizeof(bm), &bm); 41 | m_sizeBitmap = CSize(bm.bmWidth, bm.bmHeight); 42 | // get system icon size 43 | 44 | // a big icon should be twice the size of an icon + shadows 45 | SetWindowPos(NULL, 0, 0, bm.bmWidth + CX_SHADOW + 4, bm.bmHeight + CY_SHADOW + 4, 46 | SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER); 47 | } 48 | 49 | void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 50 | { 51 | CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); 52 | ENSURE(pDC != NULL); 53 | 54 | CRect rect; 55 | GetClientRect(rect); 56 | int cxClient = rect.Width(); 57 | int cyClient = rect.Height(); 58 | 59 | // draw border around icon 60 | CPen pen; 61 | pen.CreateStockObject(BLACK_PEN); 62 | CPen* pPenOld = pDC->SelectObject(&pen); 63 | pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW); 64 | if (pPenOld) 65 | pDC->SelectObject(pPenOld); 66 | 67 | // draw shadows around icon 68 | CBrush br; 69 | br.CreateStockObject(DKGRAY_BRUSH); 70 | rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient); 71 | pDC->FillRect(rect, &br); 72 | rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient); 73 | pDC->FillRect(rect, &br); 74 | 75 | // draw the bitmap contents 76 | CDC dcMem; 77 | if (!dcMem.CreateCompatibleDC(pDC)) 78 | return; 79 | CBitmap* pBitmapOld = dcMem.SelectObject(&m_bitmap); 80 | if (pBitmapOld == NULL) 81 | return; 82 | 83 | pDC->BitBlt(2, 2, m_sizeBitmap.cx, m_sizeBitmap.cy, &dcMem, 0, 0, SRCCOPY); 84 | 85 | dcMem.SelectObject(pBitmapOld); 86 | } 87 | 88 | BOOL CBigIcon::OnEraseBkgnd(CDC*) 89 | { 90 | return TRUE; // we don't do any erasing... 91 | } 92 | 93 | ///////////////////////////////////////////////////////////////////////////// 94 | -------------------------------------------------------------------------------- /src/bigicon.h: -------------------------------------------------------------------------------- 1 | // bigicon.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 | -------------------------------------------------------------------------------- /src/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 | static const int nFontSize = 10; 24 | 25 | ///////////////////////////////////////////////////////////////////////////// 26 | // CButtonDialog dialog 27 | 28 | INT_PTR CButtonDialog::DisplayMessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption, 29 | LPCTSTR lpszButtons, WORD wStyle, int nDef, int nCancel, 30 | DWORD* pHelpIDs, CWnd* pParentWnd) 31 | { 32 | CButtonDialog dlg(lpszText, lpszCaption, lpszButtons, wStyle, pHelpIDs, 33 | pParentWnd); 34 | dlg.SetDefault(nDef); 35 | dlg.SetCancel(nCancel); 36 | return dlg.DoModal(); 37 | } 38 | 39 | CButtonDialog::CButtonDialog(LPCTSTR lpszText, LPCTSTR lpszCaption, 40 | LPCTSTR lpszButtons, WORD wStyle, DWORD* pHelpIDs , 41 | CWnd* pParentWnd) : CCSDialog() 42 | { 43 | 44 | ASSERT(lpszText != NULL); 45 | ASSERT(lpszCaption != NULL); 46 | if (HIWORD(lpszText) == NULL) 47 | VERIFY(m_strText.LoadString(LOWORD((DWORD)(DWORD_PTR)lpszText))); 48 | else 49 | m_strText = lpszText; 50 | if (HIWORD(lpszCaption) == NULL) 51 | VERIFY(m_strCaption.LoadString(LOWORD((DWORD)(DWORD_PTR)lpszCaption))); 52 | else 53 | m_strCaption = lpszCaption; 54 | if (lpszButtons != NULL) 55 | AddButtons(lpszButtons); 56 | 57 | m_pParentWnd = pParentWnd; 58 | m_nDefButton = 0; 59 | m_nCancel = -1; 60 | m_pButtons = NULL; 61 | m_wStyle = wStyle; 62 | m_nBaseID = nFontSize; // don't use IDOK, IDCANCEL, etc 63 | m_hDlgTmp = NULL; 64 | 65 | LOGFONT lf; 66 | memcpy(&lf, &theApp.m_lf, sizeof(LOGFONT)); 67 | lf.lfHeight = -nFontSize; 68 | lf.lfWidth = 0; 69 | lf.lfWeight = FW_NORMAL; 70 | VERIFY(m_font.CreateFontIndirect(&lf)); 71 | 72 | // m_font.CreateFont(-nFontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 73 | // FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, 74 | // DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, szFontName); 75 | m_pHelpIDs = pHelpIDs; 76 | } 77 | 78 | CButtonDialog::~CButtonDialog() 79 | { 80 | delete [] m_pButtons; 81 | if (m_hDlgTmp != NULL) 82 | GlobalFree(m_hDlgTmp); 83 | } 84 | 85 | BEGIN_MESSAGE_MAP(CButtonDialog, CCSDialog) 86 | //{{AFX_MSG_MAP(CButtonDialog) 87 | ON_WM_CREATE() 88 | //}}AFX_MSG_MAP 89 | END_MESSAGE_MAP() 90 | 91 | ///////////////////////////////////////////////////////////////////////////// 92 | // CButtonDialog message handlers 93 | 94 | int CButtonDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) 95 | { 96 | if (m_pHelpIDs != NULL) 97 | { 98 | for (int i=0;istyle = DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | 170 | WS_CAPTION | WS_SYSMENU; 171 | lpDlgTmp->dwExtendedStyle = 0; 172 | lpDlgTmp->cdit = 0; 173 | lpDlgTmp->x = 0; 174 | lpDlgTmp->y = 0; 175 | lpDlgTmp->cx = 100; 176 | lpDlgTmp->cy = 100; 177 | 178 | LPWSTR lpStr = (LPWSTR)(lpDlgTmp + 1); /* Move ptr to the variable fields */ 179 | 180 | *lpStr++ = 0; /* No Menu resource for Message Box */ 181 | *lpStr++ = 0; /* No Class name for MessageBox */ 182 | 183 | int nLen = m_strCaption.GetLength(); 184 | wcscpy(lpStr, T2CW(m_strCaption)); 185 | 186 | lpStr += nLen+1; 187 | WORD* pWord = (WORD*)lpStr; 188 | *pWord = 10; // 10 pt font 189 | pWord++; 190 | lpStr = (LPWSTR) pWord; 191 | 192 | wcscpy(lpStr, T2W(theApp.m_lf.lfFaceName)); 193 | } 194 | 195 | ///////////////////////////////////////////////////////////////////////////// 196 | // CButtonDialog overridables 197 | 198 | BOOL CButtonDialog::OnCommand(WPARAM wParam, LPARAM /*lParam*/) 199 | { 200 | if (wParam == IDCANCEL && m_nCancel != -1) 201 | { 202 | EndDialog(m_nCancel); 203 | return TRUE; 204 | } 205 | if (::GetDlgItem(m_hWnd, (int)wParam)==NULL) 206 | return FALSE; 207 | EndDialog((int)wParam-m_nBaseID); 208 | return TRUE; 209 | } 210 | 211 | WP_INT_PTR CButtonDialog::DoModal() 212 | { 213 | ASSERT(m_strArray.GetSize() != 0); 214 | if (m_strArray.GetSize() == 0) 215 | return (m_nCancel != -1) ? m_nCancel : 0; 216 | 217 | // compute size of header 218 | // Fixed portions of DLG template header = sizeof(DLGTEMPLATE); 219 | // One null byte for menu name and one for class name = 2 220 | // Caption text plus NULL = m_strCaption.GetLength()+1 221 | int nSize = sizeof(DLGTEMPLATE); 222 | nSize += (2 + m_strCaption.GetLength()+1+lstrlen(theApp.m_lf.lfFaceName)+1)*2 +sizeof(WORD); 223 | m_hDlgTmp = GlobalAlloc(GPTR, nSize); 224 | if (m_hDlgTmp == NULL) 225 | return IDCANCEL; 226 | LPDLGTEMPLATE lpDlgTmp = (LPDLGTEMPLATE)GlobalLock(m_hDlgTmp); 227 | FillInHeader(lpDlgTmp); 228 | GlobalUnlock(m_hDlgTmp); 229 | InitModalIndirect(m_hDlgTmp); 230 | 231 | return CCSDialog::DoModal(); 232 | } 233 | 234 | ///////////////////////////////////////////////////////////////////////////// 235 | // CButtonDialog implementation 236 | 237 | void CButtonDialog::PositionControls() 238 | { 239 | CSize sizeBase = GetBaseUnits(); 240 | int nButtonHeight = (sizeBase.cy*14)/8; 241 | int nHeight = 0; 242 | int nSep,nLeftMargin,nRightMargin,nTopMargin,nBottomMargin; 243 | int nButtonAdj; 244 | int nWidth = 0; 245 | CRect rectText; 246 | 247 | // a) 5/8 screen Width 248 | // b) Caption 249 | // c) nLeftMargin ICON nSep TEXT nRightMargin 250 | // d) nLeftMargin Button1 nSep Button2 ... nRightMargin 251 | // client width is max(b,d, min(c,a)) 252 | 253 | CSize sizeIcon(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)); 254 | nSep = sizeIcon.cx/2; 255 | nLeftMargin = nSep; 256 | nRightMargin = nSep; 257 | nTopMargin = nSep; 258 | nBottomMargin = nSep; 259 | 260 | CClientDC dc(this); 261 | CFont* pOldFont = dc.SelectObject(&m_font); 262 | 263 | nButtonAdj = dc.GetTextExtent(_T("XXX"),3).cx; // padding on buttons 264 | 265 | int nScreenWidth58 = dc.GetDeviceCaps(HORZRES)*5/8; 266 | int nCaptionWidth = dc.GetTextExtent(m_strCaption, m_strCaption. 267 | GetLength()).cx; 268 | CSize sizeText = dc.GetTextExtent(m_strText,m_strText.GetLength()); 269 | int nTextIconWidth = nLeftMargin+sizeIcon.cx+nSep+sizeText.cx+nRightMargin; 270 | INT_PTR nButtons = m_strArray.GetSize(); 271 | int nButtonsWidth = (int)(nLeftMargin+nRightMargin+(nButtons-1)*nSep); 272 | INT_PTR i; 273 | for (i=0;i nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep) 288 | { 289 | sizeText.cx = nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep; 290 | // int nTextWidth = nWidth-nLeftMargin-nRightMargin-sizeIcon.cx-nSep; 291 | // rectText.SetRect(0, 0, nTextWidth, 32767); 292 | rectText.SetRect(0, 0, sizeText.cx, 32767); 293 | /* Ask DrawText for the right cy */ 294 | sizeText.cy = dc.DrawText(m_strText, m_strText.GetLength(), &rectText, 295 | DT_CALCRECT | DT_WORDBREAK | DT_EXPANDTABS | DT_NOPREFIX); 296 | } 297 | 298 | m_staticText.SetWindowPos(NULL, nSep+sizeIcon.cx+nSep, nTopMargin, 299 | sizeText.cx, sizeText.cy, SWP_NOZORDER); 300 | 301 | sizeText.cy = max(sizeText.cy, sizeIcon.cy); // at least icon height 302 | nHeight = nTopMargin + sizeText.cy + nSep + nButtonHeight + nBottomMargin; 303 | 304 | CRect rect; 305 | rect.left = (nWidth - (nButtonsWidth - nLeftMargin - nRightMargin))/2; 306 | rect.top = nTopMargin + sizeText.cy + nSep; 307 | rect.bottom = rect.top + nButtonHeight; 308 | 309 | for (i=0;iDeleteMenu(SC_CLOSE, MF_BYCOMMAND); 327 | } 328 | dc.SelectObject(pOldFont); 329 | } 330 | 331 | CSize CButtonDialog::GetBaseUnits() 332 | { 333 | CDisplayIC dc; 334 | CFont* pFont = dc.SelectObject(&m_font); 335 | TEXTMETRIC tm; 336 | VERIFY(dc.GetTextMetrics(&tm)); 337 | dc.SelectObject(pFont); 338 | return CSize(tm.tmAveCharWidth, tm.tmHeight); 339 | } 340 | 341 | LPCTSTR CButtonDialog::GetIconID(WORD wFlags) 342 | { 343 | LPCTSTR lpszIcon = NULL; 344 | wFlags &= MB_ICONMASK; 345 | if (wFlags == MB_ICONHAND) 346 | lpszIcon = IDI_HAND; 347 | else if (wFlags == MB_ICONQUESTION) 348 | lpszIcon = IDI_QUESTION; 349 | else if (wFlags == MB_ICONEXCLAMATION) 350 | lpszIcon = IDI_EXCLAMATION; 351 | else if (wFlags == MB_ICONASTERISK) 352 | lpszIcon = IDI_ASTERISK; 353 | return lpszIcon; 354 | } 355 | -------------------------------------------------------------------------------- /src/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 WP_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 | -------------------------------------------------------------------------------- /src/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 | END_MESSAGE_MAP() 40 | 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | // CCSPropertyPage 44 | 45 | CCSPropertyPage::CCSPropertyPage(UINT nIDTemplate, UINT nIDCaption) 46 | : CPropertyPage(nIDTemplate, nIDCaption) 47 | { 48 | } 49 | 50 | CCSPropertyPage::CCSPropertyPage(LPCTSTR lpszTemplateName, 51 | UINT nIDCaption) : CPropertyPage(lpszTemplateName, nIDCaption) 52 | { 53 | } 54 | 55 | BEGIN_MESSAGE_MAP(CCSPropertyPage, CPropertyPage) 56 | //{{AFX_MSG_MAP(CCSPropertyPage) 57 | //}}AFX_MSG_MAP 58 | END_MESSAGE_MAP() 59 | 60 | 61 | ///////////////////////////////////////////////////////////////////////////// 62 | // CCSPropertySheet 63 | 64 | BEGIN_MESSAGE_MAP(CCSPropertySheet, CPropertySheet) 65 | //{{AFX_MSG_MAP(CCSPropertySheet) 66 | //}}AFX_MSG_MAP 67 | END_MESSAGE_MAP() 68 | 69 | CCSPropertySheet::CCSPropertySheet(UINT nIDCaption, CWnd *pParentWnd, 70 | UINT iSelectPage) : CPropertySheet(nIDCaption, pParentWnd, iSelectPage) 71 | { 72 | } 73 | 74 | CCSPropertySheet::CCSPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd, 75 | UINT iSelectPage) : CPropertySheet(pszCaption, pParentWnd, iSelectPage) 76 | { 77 | } 78 | -------------------------------------------------------------------------------- /src/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 | // Generated message map functions 26 | //{{AFX_MSG(CCSDialog) 27 | //}}AFX_MSG 28 | DECLARE_MESSAGE_MAP() 29 | }; 30 | 31 | class CCSPropertyPage : public CPropertyPage 32 | { 33 | // Construction 34 | public: 35 | CCSPropertyPage(UINT nIDTemplate, UINT nIDCaption = 0); 36 | CCSPropertyPage(LPCTSTR lpszTemplateName, UINT nIDCaption = 0); 37 | 38 | // Implementation 39 | protected: 40 | // Generated message map functions 41 | //{{AFX_MSG(CCSPropertyPage) 42 | //}}AFX_MSG 43 | DECLARE_MESSAGE_MAP() 44 | }; 45 | 46 | class CCSPropertySheet : public CPropertySheet 47 | { 48 | // Construction 49 | public: 50 | CCSPropertySheet(UINT nIDCaption, CWnd *pParentWnd = NULL, 51 | UINT iSelectPage = 0); 52 | CCSPropertySheet(LPCTSTR pszCaption, CWnd *pParentWnd = NULL, 53 | UINT iSelectPage = 0); 54 | // Implementation 55 | protected: 56 | // Generated message map functions 57 | //{{AFX_MSG(CCSPropertySheet) 58 | //}}AFX_MSG 59 | DECLARE_MESSAGE_MAP() 60 | }; 61 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 nID) 50 | { 51 | ASSERT(idStr != NULL); 52 | CString str; 53 | VERIFY(str.LoadString(idStr)); 54 | CString strSub; 55 | AfxExtractSubString(strSub, str, nID); 56 | return strSub; 57 | } 58 | 59 | static BOOL IsConverterFormat(LPCSTR pszConverter, LPCTSTR pszPathName) 60 | { 61 | CConverter conv(pszConverter); 62 | return conv.IsFormatCorrect(pszPathName); 63 | } 64 | 65 | static BOOL IsLeadMatch(CFile& file, const BYTE* pb, UINT nCount) 66 | { 67 | // check for match at beginning of file 68 | BOOL b = FALSE; 69 | BYTE* buf = new BYTE[nCount]; 70 | 71 | TRY 72 | { 73 | file.SeekToBegin(); 74 | memset(buf, 0, nCount); 75 | file.Read(buf, nCount); 76 | if (memcmp(buf, pb, nCount) == 0) 77 | b = TRUE; 78 | } 79 | END_TRY 80 | 81 | delete [] buf; 82 | return b; 83 | } 84 | 85 | static BOOL IsWord6(LPCTSTR pszPathName) 86 | { 87 | USES_CONVERSION; 88 | BOOL bRes = FALSE; 89 | // see who created it 90 | LPSTORAGE lpStorage; 91 | SCODE sc = StgOpenStorage(T2COLE(pszPathName), NULL, 92 | STGM_READ|STGM_SHARE_EXCLUSIVE, 0, 0, &lpStorage); 93 | if (sc == NOERROR) 94 | { 95 | LPSTREAM lpStream; 96 | sc = lpStorage->OpenStream(T2COLE(szSumInfo), NULL, 97 | STGM_READ|STGM_SHARE_EXCLUSIVE, NULL, &lpStream); 98 | if (sc == NOERROR) 99 | { 100 | lpStream->Release(); 101 | bRes = TRUE; 102 | } 103 | lpStorage->Release(); 104 | } 105 | return bRes; 106 | } 107 | 108 | int GetDocTypeFromName(LPCTSTR pszPathName, CFileException& fe) 109 | { 110 | CFile file; 111 | ASSERT(pszPathName != NULL); 112 | 113 | if (!file.Open(pszPathName, CFile::modeRead | CFile::shareDenyWrite, &fe)) 114 | return -1; 115 | 116 | CFileStatus stat; 117 | VERIFY(file.GetStatus(stat)); 118 | 119 | if (stat.m_size == 0) // file is empty 120 | { 121 | CString ext = CString(pszPathName).Right(4); 122 | if (ext[0] != '.') 123 | return RD_TEXT; 124 | #if defined(_MSC_VER) && _MSC_VER >= 1400 125 | #pragma warning(suppress:6400) 126 | #endif 127 | if (lstrcmpi(ext, _T(".doc"))==0) 128 | return RD_WORDPAD; 129 | #if defined(_MSC_VER) && _MSC_VER >= 1400 130 | #pragma warning(suppress:6400) 131 | #endif 132 | if (lstrcmpi(ext, _T(".rtf"))==0) 133 | return RD_RICHTEXT; 134 | return RD_TEXT; 135 | } 136 | // RTF 137 | if (IsLeadMatch(file, byteRTFPrefix, sizeof(byteRTFPrefix))) 138 | return RD_RICHTEXT; 139 | // WORD 2 140 | if (IsLeadMatch(file, byteWord2Prefix, sizeof(byteWord2Prefix))) 141 | return RD_WINWORD2; 142 | // EXE 143 | if (IsLeadMatch(file, byteExePrefix, sizeof(byteExePrefix))) 144 | return RD_EXE; 145 | // write file can start with 31BE or 32BE depending on whether it has 146 | // OLE objects in it or not 147 | if (IsLeadMatch(file, byteWrite1Prefix, sizeof(byteWrite1Prefix)) || 148 | IsLeadMatch(file, byteWrite2Prefix, sizeof(byteWrite2Prefix))) 149 | { 150 | file.Close(); 151 | if (IsConverterFormat(szWriteConverter, pszPathName)) 152 | return RD_WRITE; 153 | else 154 | return RD_TEXT; 155 | } 156 | 157 | // test for compound file 158 | if (IsLeadMatch(file, byteCompFilePrefix, sizeof(byteCompFilePrefix))) 159 | { 160 | file.Close(); 161 | if (IsConverterFormat(szWordConverter, pszPathName)) 162 | { 163 | if (IsWord6(pszPathName)) 164 | return RD_WINWORD6; 165 | else 166 | return RD_WORDPAD; 167 | } 168 | return RD_TEXT; 169 | } 170 | return RD_TEXT; 171 | } 172 | 173 | void ScanForConverters() 174 | { 175 | static BOOL bScanned = FALSE; 176 | if (bScanned) 177 | return; 178 | 179 | for (int i=0;i= 0x700 62 | m_nAfter = m_pf.dySpaceAfter; 63 | m_nBefore = m_pf.dySpaceBefore; 64 | #endif 65 | 66 | //{{AFX_DATA_INIT(CFormatParaDlg) 67 | m_nFirst = 0; 68 | m_nLeft = 0; 69 | m_nRight = 0; 70 | m_bPageBreak = FALSE; 71 | //}}AFX_DATA_INIT 72 | } 73 | 74 | void CFormatParaDlg::DoDataExchange(CDataExchange* pDX) 75 | { 76 | CCSDialog::DoDataExchange(pDX); 77 | 78 | // semi-custom formatting for "pt" in the value for 79 | // before- and after-paragraph spacing 80 | 81 | CString strBefore; 82 | CString strAfter; 83 | 84 | if (pDX->m_bSaveAndValidate) 85 | { 86 | GetDlgItemText(IDC_EDIT_BEFORE, strBefore); 87 | m_nBefore = _ttoi(strBefore); 88 | 89 | GetDlgItemText(IDC_EDIT_AFTER, strAfter); 90 | m_nAfter = _ttoi(strAfter); 91 | } 92 | 93 | strBefore = FormatAsPoints(m_nBefore); 94 | strAfter = FormatAsPoints(m_nAfter); 95 | 96 | DDX_Text(pDX, IDC_EDIT_AFTER, strAfter); 97 | DDX_Text(pDX, IDC_EDIT_BEFORE, strBefore); 98 | 99 | //{{AFX_DATA_MAP(CFormatParaDlg) 100 | DDX_CBIndex(pDX, IDC_COMBO_ALIGNMENT, m_nAlignment); 101 | DDX_Twips(pDX, IDC_EDIT_FIRST_LINE, m_nFirst); 102 | DDV_MinMaxTwips(pDX, m_nFirst, -31680, 31680); 103 | DDX_Twips(pDX, IDC_EDIT_LEFT, m_nLeft); 104 | DDV_MinMaxTwips(pDX, m_nLeft, -31680, 31680); 105 | DDX_Twips(pDX, IDC_EDIT_RIGHT, m_nRight); 106 | DDV_MinMaxTwips(pDX, m_nRight, -31680, 31680); 107 | DDX_Check(pDX, IDC_CHECK_PAGEBREAK, m_bPageBreak); 108 | //}}AFX_DATA_MAP 109 | } 110 | 111 | BEGIN_MESSAGE_MAP(CFormatParaDlg, CCSDialog) 112 | //{{AFX_MSG_MAP(CFormatParaDlg) 113 | ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_BEFORE, OnDeltaposSpinBefore) 114 | ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_AFTER, OnDeltaposSpinAfter) 115 | //}}AFX_MSG_MAP 116 | END_MESSAGE_MAP() 117 | 118 | 119 | ///////////////////////////////////////////////////////////////////////////// 120 | // CFormatParaDlg message handlers 121 | 122 | void CFormatParaDlg::OnOK() 123 | { 124 | CCSDialog::OnOK(); 125 | m_pf.dwMask = 0; 126 | if (m_nAlignment >= 0) 127 | { 128 | ASSERT(m_nAlignment < 3); 129 | m_pf.dwMask |= PFM_ALIGNMENT; 130 | m_pf.wAlignment = (WORD)((m_nAlignment == 0) ? PFA_LEFT : 131 | (m_nAlignment == 1) ? PFA_RIGHT : PFA_CENTER); 132 | } 133 | if (m_nRight != DDXM_BLANK) 134 | m_pf.dwMask |= PFM_RIGHTINDENT; 135 | if (m_nLeft != DDXM_BLANK && m_nFirst != DDXM_BLANK) 136 | m_pf.dwMask |= PFM_STARTINDENT; 137 | if (m_nFirst != DDXM_BLANK) 138 | m_pf.dwMask |= PFM_OFFSET; 139 | 140 | #if _MFC_VER >= 0x700 141 | if (m_bPageBreak) 142 | { 143 | m_pf.dwMask |= PFM_PAGEBREAKBEFORE; 144 | m_pf.wEffects |= PFE_PAGEBREAKBEFORE; 145 | } 146 | #endif 147 | 148 | m_pf.dxRightIndent = m_nRight; 149 | m_pf.dxOffset = -m_nFirst; 150 | m_pf.dxStartIndent = m_nLeft + m_nFirst; 151 | 152 | #if _MFC_VER >= 0x700 153 | m_pf.dwMask |= PFM_SPACEAFTER | PFM_SPACEBEFORE; 154 | m_pf.dySpaceBefore = m_nBefore * 20; 155 | m_pf.dySpaceAfter = m_nAfter * 20; 156 | #endif 157 | } 158 | 159 | BOOL CFormatParaDlg::OnInitDialog() 160 | { 161 | CComboBox* pBox = (CComboBox*)GetDlgItem(IDC_COMBO_ALIGNMENT); 162 | CString str; 163 | str.LoadString(IDS_LEFT); 164 | pBox->AddString(str); 165 | str.LoadString(IDS_RIGHT); 166 | pBox->AddString(str); 167 | str.LoadString(IDS_CENTER); 168 | pBox->AddString(str); 169 | 170 | if (m_nWordWrap == 0) 171 | { 172 | GetDlgItem(IDC_COMBO_ALIGNMENT)->EnableWindow(FALSE); 173 | GetDlgItem(IDC_TEXT_ALIGNMENT)->EnableWindow(FALSE); 174 | } 175 | 176 | #if _MFC_VER >= 0x700 177 | m_bPageBreak = (m_pf.dwMask & PFM_PAGEBREAKBEFORE) && 178 | (m_pf.wEffects & PFE_PAGEBREAKBEFORE); 179 | #else 180 | m_bPageBreak = false; 181 | #endif 182 | 183 | m_nRight = (m_pf.dwMask & PFM_RIGHTINDENT) ? m_pf.dxRightIndent : DDXM_BLANK; 184 | if (m_pf.dwMask & PFM_OFFSET) 185 | { 186 | m_nFirst = -m_pf.dxOffset; 187 | m_nLeft = (m_pf.dwMask & PFM_STARTINDENT) ? 188 | m_pf.dxStartIndent + m_pf.dxOffset : DDXM_BLANK; 189 | } 190 | else 191 | m_nLeft = m_nFirst = DDXM_BLANK; 192 | 193 | #if _MFC_VER >= 0x700 194 | if (m_pf.dwMask & PFM_SPACEBEFORE) 195 | m_nBefore = m_pf.dySpaceBefore / 20; 196 | if (m_pf.dwMask & PFM_SPACEAFTER) 197 | m_nAfter = m_pf.dySpaceAfter / 20; 198 | #endif 199 | 200 | CCSDialog::OnInitDialog(); 201 | return TRUE; // return TRUE unless you set the focus to a control 202 | // EXCEPTION: OCX Property Pages should return FALSE 203 | } 204 | 205 | void CFormatParaDlg::OnDeltaposSpinBefore(NMHDR* pNMHDR, LRESULT* pResult) 206 | { 207 | NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 208 | m_nBefore = pNMUpDown->iPos; 209 | *pResult = 0; 210 | UpdateData(FALSE); 211 | } 212 | 213 | void CFormatParaDlg::OnDeltaposSpinAfter(NMHDR* pNMHDR, LRESULT* pResult) 214 | { 215 | NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR; 216 | m_nAfter = pNMUpDown->iPos; 217 | *pResult = 0; 218 | UpdateData(FALSE); 219 | } 220 | 221 | -------------------------------------------------------------------------------- /src/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(WP_PARAFORMAT& pf, CWnd* pParent = NULL); // standard constructor 20 | WP_PARAFORMAT 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 | -------------------------------------------------------------------------------- /src/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(WP_PARAFORMAT& 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 | -------------------------------------------------------------------------------- /src/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(WP_PARAFORMAT& pf, CWnd* pParent = NULL); // standard constructor 20 | ~CFormatTabDlg(); 21 | WP_PARAFORMAT 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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_CHAR_COLOR, OnCharColor) 36 | ON_COMMAND(ID_PEN_TOGGLE, OnPenToggle) 37 | //}}AFX_MSG_MAP 38 | ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR, OnUpdateControlBarMenu) 39 | ON_COMMAND_EX(ID_VIEW_TOOLBAR, OnBarCheck) 40 | ON_UPDATE_COMMAND_UI(ID_VIEW_FORMATBAR, OnUpdateControlBarMenu) 41 | ON_COMMAND_EX(ID_VIEW_FORMATBAR, OnBarCheck) 42 | ON_UPDATE_COMMAND_UI(ID_VIEW_RULER, OnUpdateControlBarMenu) 43 | ON_COMMAND_EX(ID_VIEW_RULER, OnBarCheck) 44 | ON_MESSAGE(WM_SIZECHILD, OnResizeChild) 45 | ON_MESSAGE(WPM_BARSTATE, OnBarState) 46 | END_MESSAGE_MAP() 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // arrays of IDs used to initialize control bars 50 | 51 | static UINT BASED_CODE toolButtons[] = 52 | { 53 | // same order as in the bitmap 'itoolbar.bmp' 54 | ID_EDIT_CUT, 55 | ID_EDIT_COPY, 56 | ID_EDIT_PASTE, 57 | 58 | ID_SEPARATOR, 59 | ID_PEN_TOGGLE, 60 | ID_PEN_PERIOD, 61 | ID_PEN_SPACE, 62 | ID_PEN_BACKSPACE, 63 | ID_PEN_NEWLINE, 64 | ID_PEN_LENS 65 | }; 66 | 67 | #define NUM_PEN_ITEMS 7 68 | #define NUM_PEN_TOGGLE 5 69 | 70 | static UINT BASED_CODE format[] = 71 | { 72 | // same order as in the bitmap 'format.bmp' 73 | ID_SEPARATOR, // font name combo box 74 | ID_SEPARATOR, 75 | ID_SEPARATOR, // font size combo box 76 | ID_SEPARATOR, 77 | ID_CHAR_BOLD, 78 | ID_CHAR_ITALIC, 79 | ID_CHAR_UNDERLINE, 80 | ID_CHAR_COLOR, 81 | ID_SEPARATOR, 82 | ID_PARA_LEFT, 83 | ID_PARA_CENTER, 84 | ID_PARA_RIGHT, 85 | ID_SEPARATOR, 86 | ID_INSERT_BULLET, 87 | }; 88 | 89 | ///////////////////////////////////////////////////////////////////////////// 90 | // CInPlaceFrame construction/destruction 91 | 92 | CInPlaceFrame::CInPlaceFrame() : m_wndRulerBar(FALSE) 93 | { 94 | } 95 | 96 | int CInPlaceFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 97 | { 98 | if (COleIPFrameWnd::OnCreate(lpCreateStruct) == -1) 99 | return -1; 100 | 101 | // CResizeBar implements in-place resizing. 102 | if (!m_wndResizeBar.Create(this)) 103 | { 104 | TRACE0("Failed to create resize bar\n"); 105 | return -1; // fail to create 106 | } 107 | 108 | if (!CreateRulerBar(this)) 109 | return FALSE; 110 | 111 | // By default, it is a good idea to register a drop-target that does 112 | // nothing with your frame window. This prevents drops from 113 | // "falling through" to a container that supports drag-drop. 114 | m_dropTarget.Register(this); 115 | 116 | return 0; 117 | } 118 | 119 | // OnCreateControlBars is called by the framework to create control bars on the 120 | // container application's windows. pWndFrame is the top level frame window of 121 | // the container and is always non-NULL. pWndDoc is the doc level frame window 122 | // and will be NULL when the container is an SDI application. A server 123 | // application can place MFC control bars on either window. 124 | BOOL CInPlaceFrame::OnCreateControlBars(CFrameWnd* pWndFrame, CFrameWnd* /*pWndDoc*/) 125 | { 126 | if (!CreateToolBar(pWndFrame)) 127 | return FALSE; 128 | 129 | if (!CreateFormatBar(pWndFrame)) 130 | return FALSE; 131 | 132 | // set owner to this window, so messages are delivered to correct app 133 | m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 134 | m_wndFormatBar.EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM); 135 | pWndFrame->EnableDocking(CBRS_ALIGN_ANY); 136 | pWndFrame->DockControlBar(&m_wndToolBar); 137 | pWndFrame->DockControlBar(&m_wndFormatBar); 138 | 139 | m_wndToolBar.SetOwner(this); 140 | m_wndFormatBar.SetOwner(this); 141 | m_wndRulerBar.SetOwner(this); 142 | OnBarState(1, RD_EMBEDDED); //load bar state 143 | return TRUE; 144 | } 145 | 146 | BOOL CInPlaceFrame::CreateToolBar(CWnd* pWndFrame) 147 | { 148 | // Create toolbar on client's frame window 149 | ASSERT(m_wndToolBar.m_hWnd == NULL); 150 | int nPen = GetSystemMetrics(SM_PENWINDOWS) ? NUM_PEN_TOGGLE : 151 | NUM_PEN_ITEMS; 152 | UINT nID = theApp.m_bLargeIcons ? 153 | IDR_SRVR_INPLACE_BIG : IDR_SRVR_INPLACE; 154 | if (!m_wndToolBar.Create(pWndFrame, WS_CHILD|WS_VISIBLE|CBRS_TOP| 155 | CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)|| 156 | !m_wndToolBar.LoadBitmap(nID) || 157 | !m_wndToolBar.SetButtons(toolButtons, 158 | sizeof(toolButtons)/sizeof(UINT) - nPen)) 159 | { 160 | TRACE0("Failed to create toolbar\n"); 161 | return FALSE; // fail to create 162 | } 163 | if (theApp.m_bLargeIcons) 164 | m_wndToolBar.SetSizes(CSize(31,30), CSize(24,24)); 165 | else 166 | m_wndToolBar.SetSizes(CSize(23,22), CSize(16,16)); 167 | CString str; 168 | str.LoadString(IDS_TITLE_TOOLBAR); 169 | m_wndToolBar.SetWindowText(str); 170 | return TRUE; 171 | } 172 | 173 | BOOL CInPlaceFrame::CreateFormatBar(CWnd* pWndFrame) 174 | { 175 | ASSERT(m_wndFormatBar.m_hWnd == NULL); 176 | m_wndFormatBar.m_hWndOwner = m_hWnd; 177 | UINT nID = theApp.m_bLargeIcons ? IDB_FORMATBAR_BIG : IDB_FORMATBAR; 178 | if (!m_wndFormatBar.Create(pWndFrame, WS_CHILD|WS_VISIBLE|CBRS_TOP| 179 | CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC, ID_VIEW_FORMATBAR) || 180 | !m_wndFormatBar.LoadBitmap(nID) || 181 | !m_wndFormatBar.SetButtons(format, 182 | sizeof(format)/sizeof(UINT))) 183 | { 184 | TRACE0("Failed to create FormatBar\n"); 185 | return FALSE; // fail to create 186 | } 187 | 188 | if (theApp.m_bLargeIcons) 189 | m_wndFormatBar.SetSizes(CSize(31,30), CSize(24,24)); 190 | else 191 | m_wndFormatBar.SetSizes(CSize(23,22), CSize(16,16)); 192 | CString str; 193 | str.LoadString(IDS_TITLE_FORMATBAR); 194 | m_wndFormatBar.SetWindowText(str); 195 | m_wndFormatBar.PositionCombos(); 196 | return TRUE; 197 | } 198 | 199 | BOOL CInPlaceFrame::CreateRulerBar(CWnd* pWndFrame) 200 | { 201 | if (!m_wndRulerBar.Create(pWndFrame, 202 | WS_CHILD|WS_VISIBLE|CBRS_ALIGN_TOP|CBRS_HIDE_INPLACE, ID_VIEW_RULER)) 203 | { 204 | TRACE0("Failed to create ruler\n"); 205 | return FALSE; // fail to create 206 | } 207 | return TRUE; 208 | } 209 | 210 | ///////////////////////////////////////////////////////////////////////////// 211 | // CInPlaceFrame Operations 212 | 213 | ///////////////////////////////////////////////////////////////////////////// 214 | // CInPlaceFrame diagnostics 215 | 216 | #ifdef _DEBUG 217 | void CInPlaceFrame::AssertValid() const 218 | { 219 | COleIPFrameWnd::AssertValid(); 220 | } 221 | 222 | void CInPlaceFrame::Dump(CDumpContext& dc) const 223 | { 224 | COleIPFrameWnd::Dump(dc); 225 | } 226 | #endif //_DEBUG 227 | 228 | ///////////////////////////////////////////////////////////////////////////// 229 | // CInPlaceFrame commands 230 | 231 | void CInPlaceFrame::OnDestroy() 232 | { 233 | m_wndToolBar.DestroyWindow(); 234 | m_wndFormatBar.DestroyWindow(); 235 | COleIPFrameWnd::OnDestroy(); 236 | } 237 | 238 | void CInPlaceFrame::RepositionFrame(LPCRECT lpPosRect, LPCRECT lpClipRect) 239 | { 240 | CRect rectNew = lpPosRect; 241 | rectNew.left -= HORZ_TEXTOFFSET; 242 | rectNew.top -= VERT_TEXTOFFSET; 243 | m_wndResizeBar.BringWindowToTop(); 244 | COleIPFrameWnd::RepositionFrame(&rectNew, lpClipRect); 245 | CWnd* pWnd = GetActiveView(); 246 | if (pWnd != NULL) 247 | pWnd->BringWindowToTop(); 248 | m_wndRulerBar.BringWindowToTop(); 249 | } 250 | 251 | void CInPlaceFrame::RecalcLayout(BOOL bNotify) 252 | { 253 | if (m_wndResizeBar.m_hWnd != NULL) 254 | m_wndResizeBar.BringWindowToTop(); 255 | COleIPFrameWnd::RecalcLayout(bNotify); 256 | CWnd* pWnd = GetActiveView(); 257 | if (pWnd != NULL) 258 | pWnd->BringWindowToTop(); 259 | if (m_wndRulerBar.m_hWnd != NULL) 260 | m_wndRulerBar.BringWindowToTop(); 261 | 262 | // at least 12 pt region plus ruler if it exists 263 | CDisplayIC dc; 264 | CSize size; 265 | size.cy = MulDiv(12, dc.GetDeviceCaps(LOGPIXELSY), 72)+1; 266 | size.cx = dc.GetDeviceCaps(LOGPIXELSX)/4; // 1/4" 267 | size.cx += HORZ_TEXTOFFSET; //adjust for offset 268 | size.cy += VERT_TEXTOFFSET; 269 | if (m_wndRulerBar.m_hWnd != NULL && m_wndRulerBar.IsVisible()) 270 | { 271 | CRect rect; 272 | m_wndRulerBar.GetWindowRect(&rect); 273 | size.cy += rect.Height(); 274 | } 275 | m_wndResizeBar.SetMinSize(size); 276 | } 277 | 278 | void CInPlaceFrame::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType) 279 | { 280 | COleIPFrameWnd::CalcWindowRect(lpClientRect, nAdjustType); 281 | } 282 | 283 | LRESULT CInPlaceFrame::OnResizeChild(WPARAM /*wParam*/, LPARAM lParam) 284 | { 285 | // notify the container that the rectangle has changed! 286 | CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument(); 287 | if (pDoc == NULL) 288 | return 0; 289 | 290 | ASSERT(pDoc->IsKindOf(RUNTIME_CLASS(CWordPadDoc))); 291 | 292 | // get new rect and parent 293 | CRect rectNew; 294 | rectNew.CopyRect((LPCRECT)lParam); 295 | CWnd* pParentWnd = GetParent(); 296 | ASSERT_VALID(pParentWnd); 297 | 298 | // convert rectNew relative to pParentWnd 299 | ClientToScreen(&rectNew); 300 | pParentWnd->ScreenToClient(&rectNew); 301 | 302 | if (m_wndRulerBar.GetStyle()&WS_VISIBLE) 303 | { 304 | CRect rect; 305 | m_wndRulerBar.GetWindowRect(&rect); 306 | rectNew.top += rect.Height(); 307 | } 308 | rectNew.left += HORZ_TEXTOFFSET; 309 | rectNew.top += VERT_TEXTOFFSET; 310 | 311 | // adjust the new rectangle for the current control bars 312 | CWnd* pLeftOver = GetDlgItem(AFX_IDW_PANE_FIRST); 313 | ENSURE(pLeftOver != NULL); 314 | CRect rectCur = m_rectPos; 315 | pLeftOver->CalcWindowRect(&rectCur, CWnd::adjustOutside); 316 | rectNew.left += m_rectPos.left - rectCur.left; 317 | rectNew.top += m_rectPos.top - rectCur.top; 318 | rectNew.right -= rectCur.right - m_rectPos.right; 319 | rectNew.bottom -= rectCur.bottom - m_rectPos.bottom; 320 | OnRequestPositionChange(rectNew); 321 | 322 | return 0; 323 | } 324 | 325 | LONG_PTR CInPlaceFrame::OnBarState(UINT_PTR wParam, LONG_PTR lParam) 326 | { 327 | if (lParam == -1) 328 | return 0L; 329 | if (wParam == 0) 330 | { 331 | GetDockState(theApp.GetDockState(RD_EMBEDDED)); 332 | ENSURE(m_pMainFrame != NULL); 333 | m_pMainFrame->GetDockState(theApp.GetDockState(RD_EMBEDDED, FALSE)); 334 | } 335 | else 336 | { 337 | SetDockState(theApp.GetDockState(RD_EMBEDDED)); 338 | m_pMainFrame->SetDockState(theApp.GetDockState(RD_EMBEDDED, FALSE)); 339 | } 340 | return 0L; 341 | } 342 | 343 | void CInPlaceFrame::OnCharColor() 344 | { 345 | CColorMenu colorMenu; 346 | CRect rc; 347 | int index = m_wndFormatBar.CommandToIndex(ID_CHAR_COLOR); 348 | m_wndFormatBar.GetItemRect(index, &rc); 349 | m_wndFormatBar.ClientToScreen(rc); 350 | colorMenu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,rc.left,rc.bottom, this); 351 | } 352 | 353 | void CInPlaceFrame::OnPenToggle() 354 | { 355 | static int nPen = 0; 356 | m_wndToolBar.SetButtons(toolButtons, sizeof(toolButtons)/sizeof(UINT) - nPen); 357 | nPen = (nPen == 0) ? NUM_PEN_TOGGLE : 0; 358 | m_wndToolBar.Invalidate(); 359 | m_wndToolBar.GetParentFrame()->RecalcLayout(); 360 | } 361 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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_WM_DROPFILES() 38 | ON_COMMAND(ID_CHAR_COLOR, OnCharColor) 39 | ON_COMMAND(ID_PEN_TOGGLE, OnPenToggle) 40 | ON_WM_FONTCHANGE() 41 | ON_WM_QUERYNEWPALETTE() 42 | ON_WM_PALETTECHANGED() 43 | ON_WM_DEVMODECHANGE() 44 | //}}AFX_MSG_MAP 45 | // Global help commands 46 | ON_UPDATE_COMMAND_UI(ID_VIEW_FORMATBAR, OnUpdateControlBarMenu) 47 | ON_UPDATE_COMMAND_UI(ID_VIEW_RULER, OnUpdateControlBarMenu) 48 | ON_MESSAGE(WPM_BARSTATE, OnBarState) 49 | ON_REGISTERED_MESSAGE(CWordPadApp::m_nOpenMsg, OnOpenMsg) 50 | ON_COMMAND_EX(ID_VIEW_STATUS_BAR, OnBarCheck) 51 | ON_COMMAND_EX(ID_VIEW_TOOLBAR, OnBarCheck) 52 | ON_COMMAND_EX(ID_VIEW_FORMATBAR, OnBarCheck) 53 | ON_COMMAND_EX(ID_VIEW_RULER, OnBarCheck) 54 | END_MESSAGE_MAP() 55 | 56 | ///////////////////////////////////////////////////////////////////////////// 57 | // arrays of IDs used to initialize control bars 58 | 59 | // toolbar buttons - IDs are command buttons 60 | static UINT BASED_CODE toolbar[] = 61 | { 62 | // same order as in the bitmap 'toolbar.bmp' 63 | // (int nBitmap, int nCommand, BYTE byteState, BYTE byteStyle, DWORD dw, int nString) 64 | ID_FILE_NEW, 65 | ID_FILE_OPEN, 66 | ID_FILE_SAVE, 67 | ID_SEPARATOR, 68 | ID_FILE_PRINT_DIRECT, 69 | ID_FILE_PRINT_PREVIEW, 70 | ID_SEPARATOR, 71 | ID_EDIT_FIND, 72 | ID_SEPARATOR, 73 | ID_EDIT_CUT, 74 | ID_EDIT_COPY, 75 | ID_EDIT_PASTE, 76 | ID_EDIT_UNDO, 77 | ID_SEPARATOR, 78 | ID_INSERT_DATE_TIME, 79 | ID_SEPARATOR, 80 | ID_PEN_TOGGLE, 81 | ID_PEN_PERIOD, 82 | ID_PEN_SPACE, 83 | ID_PEN_BACKSPACE, 84 | ID_PEN_NEWLINE, 85 | ID_PEN_LENS 86 | }; 87 | 88 | #define NUM_PEN_ITEMS 7 89 | #define NUM_PEN_TOGGLE 5 90 | 91 | static UINT BASED_CODE format[] = 92 | { 93 | // same order as in the bitmap 'format.bmp' 94 | ID_SEPARATOR, // font name combo box 95 | ID_SEPARATOR, 96 | ID_SEPARATOR, // font size combo box 97 | ID_SEPARATOR, 98 | ID_CHAR_BOLD, 99 | ID_CHAR_ITALIC, 100 | ID_CHAR_UNDERLINE, 101 | ID_CHAR_COLOR, 102 | ID_SEPARATOR, 103 | ID_PARA_LEFT, 104 | ID_PARA_CENTER, 105 | ID_PARA_RIGHT, 106 | ID_SEPARATOR, 107 | ID_INSERT_BULLET, 108 | }; 109 | 110 | static UINT BASED_CODE indicators[] = 111 | { 112 | ID_SEPARATOR, // status line indicator 113 | ID_INDICATOR_CAPS, 114 | ID_INDICATOR_NUM, 115 | }; 116 | 117 | ///////////////////////////////////////////////////////////////////////////// 118 | // CMainFrame construction/destruction 119 | 120 | CMainFrame::CMainFrame() 121 | { 122 | m_hIconDoc = theApp.LoadIcon(IDI_ICON_DOC); 123 | m_hIconText = theApp.LoadIcon(IDI_ICON_TEXT); 124 | m_hIconWrite = theApp.LoadIcon(IDI_ICON_WRITE); 125 | } 126 | 127 | CMainFrame::~CMainFrame() 128 | { 129 | } 130 | 131 | BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 132 | { 133 | WNDCLASS wndcls; 134 | 135 | BOOL bRes = CFrameWnd::PreCreateWindow(cs); 136 | HINSTANCE hInst = AfxGetInstanceHandle(); 137 | 138 | // see if the class already exists 139 | if (!::GetClassInfo(hInst, szWordPadClass, &wndcls)) 140 | { 141 | // get default stuff 142 | ::GetClassInfo(hInst, cs.lpszClass, &wndcls); 143 | wndcls.style &= ~(CS_HREDRAW|CS_VREDRAW); 144 | // register a new class 145 | wndcls.lpszClassName = szWordPadClass; 146 | wndcls.hIcon = ::LoadIcon(hInst, MAKEINTRESOURCE(IDR_MAINFRAME)); 147 | ASSERT(wndcls.hIcon != NULL); 148 | if (!AfxRegisterClass(&wndcls)) 149 | AfxThrowResourceException(); 150 | } 151 | cs.lpszClass = szWordPadClass; 152 | CRect rect = theApp.m_rectInitialFrame; 153 | if (rect.Width() > 0 && rect.Height() > 0) 154 | { 155 | // make sure window will be visible 156 | CDisplayIC dc; 157 | CRect rectDisplay(0, 0, dc.GetDeviceCaps(HORZRES), 158 | dc.GetDeviceCaps(VERTRES)); 159 | if (rectDisplay.PtInRect(rect.TopLeft()) && 160 | rectDisplay.PtInRect(rect.BottomRight())) 161 | { 162 | cs.x = rect.left; 163 | cs.y = rect.top; 164 | cs.cx = rect.Width(); 165 | cs.cy = rect.Height(); 166 | } 167 | } 168 | return bRes; 169 | } 170 | 171 | int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 172 | { 173 | if (CFrameWnd::OnCreate(lpCreateStruct) == -1) 174 | return -1; 175 | 176 | if (!CreateToolBar()) 177 | return -1; 178 | 179 | if (!CreateFormatBar()) 180 | return -1; 181 | 182 | if (!CreateStatusBar()) 183 | return -1; 184 | 185 | EnableDocking(CBRS_ALIGN_ANY); 186 | 187 | if (!CreateRulerBar()) 188 | return -1; 189 | 190 | m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); 191 | m_wndFormatBar.EnableDocking(CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM); 192 | DockControlBar(&m_wndToolBar); 193 | DockControlBar(&m_wndFormatBar); 194 | 195 | CWnd* pView = GetDlgItem(AFX_IDW_PANE_FIRST); 196 | if (pView != NULL) 197 | { 198 | pView->SetWindowPos(&wndBottom, 0, 0, 0, 0, 199 | SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE); 200 | } 201 | 202 | return 0; 203 | } 204 | 205 | BOOL CMainFrame::CreateToolBar() 206 | { 207 | int nPen = GetSystemMetrics(SM_PENWINDOWS) ? NUM_PEN_TOGGLE : 208 | NUM_PEN_ITEMS; 209 | UINT nID = theApp.m_bLargeIcons ? IDR_MAINFRAME1_BIG : 210 | IDR_MAINFRAME1; 211 | if (!m_wndToolBar.Create(this, 212 | WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC)|| 213 | !m_wndToolBar.LoadBitmap(nID) || 214 | !m_wndToolBar.SetButtons(toolbar, sizeof(toolbar)/sizeof(UINT) - nPen)) 215 | { 216 | TRACE0("Failed to create toolbar\n"); 217 | return FALSE; // fail to create 218 | } 219 | if (theApp.m_bLargeIcons) 220 | m_wndToolBar.SetSizes(CSize(31,30), CSize(24,24)); 221 | else 222 | m_wndToolBar.SetSizes(CSize(23,22), CSize(16,16)); 223 | CString str; 224 | str.LoadString(IDS_TITLE_TOOLBAR); 225 | m_wndToolBar.SetWindowText(str); 226 | return TRUE; 227 | } 228 | 229 | BOOL CMainFrame::CreateFormatBar() 230 | { 231 | UINT nID = theApp.m_bLargeIcons ? IDB_FORMATBAR_BIG : IDB_FORMATBAR; 232 | if (!m_wndFormatBar.Create(this, 233 | WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE|CBRS_SIZE_DYNAMIC, 234 | ID_VIEW_FORMATBAR) || 235 | !m_wndFormatBar.LoadBitmap(nID) || 236 | !m_wndFormatBar.SetButtons(format, sizeof(format)/sizeof(UINT))) 237 | { 238 | TRACE0("Failed to create FormatBar\n"); 239 | return FALSE; // fail to create 240 | } 241 | 242 | if (theApp.m_bLargeIcons) 243 | m_wndFormatBar.SetSizes(CSize(31,30), CSize(24,24)); 244 | else 245 | m_wndFormatBar.SetSizes(CSize(23,22), CSize(16,16)); 246 | CString str; 247 | str.LoadString(IDS_TITLE_FORMATBAR); 248 | m_wndFormatBar.SetWindowText(str); 249 | m_wndFormatBar.PositionCombos(); 250 | return TRUE; 251 | } 252 | 253 | BOOL CMainFrame::CreateRulerBar() 254 | { 255 | if (!m_wndRulerBar.Create(this, 256 | WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_HIDE_INPLACE, ID_VIEW_RULER)) 257 | { 258 | TRACE0("Failed to create ruler\n"); 259 | return FALSE; // fail to create 260 | } 261 | return TRUE; 262 | } 263 | 264 | BOOL CMainFrame::CreateStatusBar() 265 | { 266 | if (!m_wndStatusBar.Create(this) || 267 | !m_wndStatusBar.SetIndicators(indicators, 268 | sizeof(indicators)/sizeof(UINT))) 269 | { 270 | TRACE0("Failed to create status bar\n"); 271 | return FALSE; // fail to create 272 | } 273 | return TRUE; 274 | } 275 | 276 | ///////////////////////////////////////////////////////////////////////////// 277 | // CMainFrame Operations 278 | 279 | HICON CMainFrame::GetIcon(int nDocType) 280 | { 281 | switch (nDocType) 282 | { 283 | case RD_WINWORD6: 284 | case RD_WORDPAD: 285 | case RD_EMBEDDED: 286 | case RD_RICHTEXT: 287 | return m_hIconDoc; 288 | case RD_TEXT: 289 | case RD_OEMTEXT: 290 | return m_hIconText; 291 | case RD_WRITE: 292 | return m_hIconWrite; 293 | } 294 | return m_hIconDoc; 295 | } 296 | 297 | ///////////////////////////////////////////////////////////////////////////// 298 | // CMainFrame diagnostics 299 | 300 | #ifdef _DEBUG 301 | void CMainFrame::AssertValid() const 302 | { 303 | CFrameWnd::AssertValid(); 304 | } 305 | 306 | void CMainFrame::Dump(CDumpContext& dc) const 307 | { 308 | CFrameWnd::Dump(dc); 309 | } 310 | 311 | #endif //_DEBUG 312 | 313 | ///////////////////////////////////////////////////////////////////////////// 314 | // CMainFrame message handlers 315 | 316 | void CMainFrame::OnFontChange() 317 | { 318 | m_wndFormatBar.SendMessage(CWordPadApp::m_nPrinterChangedMsg); 319 | } 320 | 321 | void CMainFrame::OnDevModeChange(LPTSTR lpDeviceName) 322 | { 323 | theApp.NotifyPrinterChanged(); 324 | CFrameWnd::OnDevModeChange(lpDeviceName); //sends message to descendants 325 | } 326 | 327 | void CMainFrame::OnSysColorChange() 328 | { 329 | CFrameWnd::OnSysColorChange(); 330 | m_wndRulerBar.SendMessage(WM_SYSCOLORCHANGE); 331 | } 332 | 333 | void CMainFrame::ActivateFrame(int nCmdShow) 334 | { 335 | CFrameWnd::ActivateFrame(nCmdShow); 336 | // make sure and display the toolbar, ruler, etc while loading a document. 337 | OnIdleUpdateCmdUI(); 338 | UpdateWindow(); 339 | } 340 | 341 | void CMainFrame::OnSize(UINT nType, int cx, int cy) 342 | { 343 | CFrameWnd::OnSize(nType, cx, cy); 344 | theApp.m_bMaximized = (nType == SIZE_MAXIMIZED); 345 | if (nType == SIZE_RESTORED) 346 | GetWindowRect(theApp.m_rectInitialFrame); 347 | } 348 | 349 | LONG_PTR CMainFrame::OnBarState(UINT_PTR wParam, LONG_PTR lParam) 350 | { 351 | if (lParam == -1) 352 | return 0L; 353 | ASSERT(lParam != RD_EMBEDDED); 354 | if (wParam == 0) 355 | { 356 | CDockState& ds = theApp.GetDockState(lParam); 357 | ds.Clear(); // empty out the dock state 358 | GetDockState(ds); 359 | } 360 | else 361 | { 362 | if (IsTextType(lParam)) 363 | { 364 | // in text mode hide the ruler and format bar so that it is the default 365 | CControlBar* pBar = GetControlBar(ID_VIEW_FORMATBAR); 366 | if (pBar != NULL) 367 | pBar->ShowWindow(SW_HIDE); 368 | pBar = GetControlBar(ID_VIEW_RULER); 369 | if (pBar != NULL) 370 | pBar->ShowWindow(SW_HIDE); 371 | } 372 | HICON hIcon = GetIcon((int)lParam); 373 | SendMessage(WM_SETICON, TRUE, (LPARAM)hIcon); 374 | SetDockState(theApp.GetDockState(lParam)); 375 | } 376 | return 0L; 377 | } 378 | 379 | void CMainFrame::OnMove(int x, int y) 380 | { 381 | CFrameWnd::OnMove(x, y); 382 | WINDOWPLACEMENT wp; 383 | wp.length = sizeof(wp); 384 | GetWindowPlacement(&wp); 385 | theApp.m_rectInitialFrame = wp.rcNormalPosition; 386 | CView* pView = GetActiveView(); 387 | if (pView != NULL) 388 | pView->SendMessage(WM_MOVE); 389 | } 390 | 391 | LONG_PTR CMainFrame::OnOpenMsg(UINT_PTR, LONG_PTR lParam) 392 | { 393 | TCHAR szAtomName[256]; 394 | szAtomName[0] = NULL; 395 | GlobalGetAtomName((ATOM)lParam, szAtomName, 256); 396 | CWordPadDoc* pDoc = (CWordPadDoc*)GetActiveDocument(); 397 | if (szAtomName[0] != NULL && pDoc != NULL) 398 | { 399 | if (lstrcmpi(szAtomName, pDoc->GetPathName()) == 0) 400 | return TRUE; 401 | } 402 | return FALSE; 403 | } 404 | 405 | void CMainFrame::OnDropFiles(HDROP hDropInfo) 406 | { 407 | TCHAR szFileName[_MAX_PATH]; 408 | ::DragQueryFile(hDropInfo, 0, szFileName, _MAX_PATH); 409 | ::DragFinish(hDropInfo); 410 | theApp.OpenDocumentFile(szFileName); 411 | } 412 | 413 | void CMainFrame::OnCharColor() 414 | { 415 | CColorMenu colorMenu; 416 | CRect rc; 417 | int index = m_wndFormatBar.CommandToIndex(ID_CHAR_COLOR); 418 | m_wndFormatBar.GetItemRect(index, &rc); 419 | m_wndFormatBar.ClientToScreen(rc); 420 | colorMenu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,rc.left,rc.bottom, this); 421 | } 422 | 423 | void CMainFrame::OnPenToggle() 424 | { 425 | static int nPen = 0; 426 | m_wndToolBar.SetButtons(toolbar, sizeof(toolbar)/sizeof(UINT) - nPen); 427 | nPen = (nPen == 0) ? NUM_PEN_TOGGLE : 0; 428 | m_wndToolBar.Invalidate(); 429 | m_wndToolBar.GetParentFrame()->RecalcLayout(); 430 | } 431 | 432 | BOOL CMainFrame::OnQueryNewPalette() 433 | { 434 | CView* pView = GetActiveView(); 435 | if (pView != NULL) 436 | return (BOOL)pView->SendMessage(WM_QUERYNEWPALETTE); 437 | return FALSE; 438 | } 439 | 440 | void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) 441 | { 442 | CView* pView = GetActiveView(); 443 | if (pView != NULL) 444 | pView->SendMessage(WM_PALETTECHANGED, (WPARAM)pFocusWnd->GetSafeHwnd()); 445 | } 446 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/makefile: -------------------------------------------------------------------------------- 1 | OUTDIR=Release 2 | INTDIR=Release 3 | USE_DLL=0 4 | 5 | CPP=cl.exe 6 | RSC=rc.exe 7 | LINK32=link.exe 8 | 9 | CXX_MAKE_PCH=/Yc"stdafx.h" 10 | CXX_USE_PCH=/Yu"stdafx.h" 11 | 12 | !IF $(USE_DLL)==1 13 | CXX_RUNTIME=/MD /D "_AFXDLL" 14 | RC_RUNTIME=/d "_AFXDLL" 15 | !ELSE 16 | CXX_RUNTIME=/MT 17 | RC_RUNTIME= 18 | !ENDIF 19 | 20 | CXXFLAGS=/nologo /W3 /EHsc /Os /Z7 $(CXX_RUNTIME) /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /Fp"$(INTDIR)\wordpad.pch" /Fo"$(INTDIR)\\" /c 21 | RCFLAGS=/l 0x409 /fo"$(INTDIR)\wordpad.res" /d "NDEBUG" $(RC_RUNTIME) 22 | 23 | LDFLAGS=/nologo /entry:"wWinMainCRTStartup" /subsystem:windows /incremental:no /debug /pdb:"$(OUTDIR)\wordpad.pdb" /out:"$(OUTDIR)\wordpad.exe" 24 | 25 | !IF [$(CC) 2>&1 | find "x86" >NUL]==0 26 | LDFLAGS=$(LDFLAGS) -MACHINE:X86 27 | !ELSE 28 | !IF [$(CC) 2>&1 | find "x64" >NUL]==0 29 | LDFLAGS=$(LDFLAGS) -MACHINE:X64 30 | !ELSE 31 | !IF [$(CC) 2>&1 | find "AMD64" >NUL]==0 32 | LDFLAGS=$(LDFLAGS) -MACHINE:AMD64 33 | !ELSE 34 | !IF [$(CC) 2>&1 | find "ARM64" >NUL]==0 35 | LDFLAGS=$(LDFLAGS) -MACHINE:ARM64 36 | !ENDIF # ARM64 37 | !ENDIF # AMD64 38 | !ENDIF # X64 39 | !ENDIF # X86 40 | 41 | ALL : "$(OUTDIR)\wordpad.exe" 42 | 43 | CLEAN : 44 | -@if exist "$(INTDIR)" rmdir /s /q "$(INTDIR)" 45 | -@if exist "$(OUTDIR)" rmdir /s /q "$(OUTDIR)" 46 | 47 | "$(OUTDIR)" : 48 | @if not exist "$(OUTDIR)" mkdir "$(OUTDIR)" 49 | 50 | LINK32_OBJS= \ 51 | "$(INTDIR)\stdafx.obj" \ 52 | "$(INTDIR)\about.obj" \ 53 | "$(INTDIR)\bigicon.obj" \ 54 | "$(INTDIR)\buttondi.obj" \ 55 | "$(INTDIR)\chicdial.obj" \ 56 | "$(INTDIR)\cntritem.obj" \ 57 | "$(INTDIR)\colorlis.obj" \ 58 | "$(INTDIR)\datedial.obj" \ 59 | "$(INTDIR)\ddxm.obj" \ 60 | "$(INTDIR)\docopt.obj" \ 61 | "$(INTDIR)\doctype.obj" \ 62 | "$(INTDIR)\filenewd.obj" \ 63 | "$(INTDIR)\formatba.obj" \ 64 | "$(INTDIR)\formatpa.obj" \ 65 | "$(INTDIR)\formatta.obj" \ 66 | "$(INTDIR)\ipframe.obj" \ 67 | "$(INTDIR)\key.obj" \ 68 | "$(INTDIR)\listdlg.obj" \ 69 | "$(INTDIR)\mainfrm.obj" \ 70 | "$(INTDIR)\multconv.obj" \ 71 | "$(INTDIR)\options.obj" \ 72 | "$(INTDIR)\optionsh.obj" \ 73 | "$(INTDIR)\pageset.obj" \ 74 | "$(INTDIR)\ruler.obj" \ 75 | "$(INTDIR)\splash.obj" \ 76 | "$(INTDIR)\srvritem.obj" \ 77 | "$(INTDIR)\strings.obj" \ 78 | "$(INTDIR)\unitspag.obj" \ 79 | "$(INTDIR)\wordpad.obj" \ 80 | "$(INTDIR)\wordpdoc.obj" \ 81 | "$(INTDIR)\wordpvw.obj" \ 82 | "$(INTDIR)\wordpad.res" 83 | 84 | "$(OUTDIR)\wordpad.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) 85 | @echo $@ 86 | @$(LINK32) $(LDFLAGS) $(LINK32_OBJS) 87 | 88 | $(INTDIR)\stdafx.obj: stdafx.h stdafx.cpp 89 | @$(CPP) $(CXXFLAGS) $(CXX_MAKE_PCH) stdafx.cpp 90 | 91 | # YMAKE needs to build stdafx.obj first so the precompiled header exists, 92 | # then use it. NMAKE processes things in order one at a time, so this is 93 | # achieved by having stdafx.obj listed as the first object. 94 | !IFDEF _YMAKE_VER 95 | .cpp{$(INTDIR)}.obj: "$(INTDIR)\stdafx.obj" 96 | @$(CPP) $(CXXFLAGS) $(CXX_USE_PCH) $< 97 | !ELSE 98 | .cpp{$(INTDIR)}.obj: 99 | @$(CPP) $(CXXFLAGS) $(CXX_USE_PCH) $< 100 | !ENDIF 101 | 102 | .rc{$(INTDIR)}.res: 103 | @$(RC) $(RCFLAGS) $< 104 | 105 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/multconv.cpp: -------------------------------------------------------------------------------- 1 | // convert.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 "multconv.h" 15 | #include "mswd6_32.h" 16 | 17 | #ifdef _DEBUG 18 | #undef THIS_FILE 19 | static char BASED_CODE THIS_FILE[] = __FILE__; 20 | #endif 21 | 22 | #ifdef CONVERTERS 23 | CConverter* CConverter::m_pThis = NULL; 24 | #endif 25 | 26 | #define BUFFSIZE 4096 27 | 28 | CTrackFile::CTrackFile(CFrameWnd* pWnd) : CFile() 29 | { 30 | m_nLastPercent = -1; 31 | m_dwLength = 0; 32 | m_pFrameWnd = pWnd; 33 | VERIFY(m_strComplete.LoadString(IDS_COMPLETE)); 34 | VERIFY(m_strWait.LoadString(IDS_PLEASE_WAIT)); 35 | VERIFY(m_strSaving.LoadString(IDS_SAVING)); 36 | // OutputPercent(0); 37 | } 38 | 39 | CTrackFile::~CTrackFile() 40 | { 41 | OutputPercent(100); 42 | if (m_pFrameWnd != NULL) 43 | m_pFrameWnd->SetMessageText(AFX_IDS_IDLEMESSAGE); 44 | } 45 | 46 | UINT CTrackFile::Read(void FAR* lpBuf, UINT nCount) 47 | { 48 | UINT n = CFile::Read(lpBuf, nCount); 49 | if (m_dwLength != 0) 50 | OutputPercent((int)((GetPosition()*100)/m_dwLength)); 51 | return n; 52 | } 53 | 54 | void CTrackFile::Write(const void FAR* lpBuf, UINT nCount) 55 | { 56 | CFile::Write(lpBuf, nCount); 57 | OutputString(m_strSaving); 58 | // if (m_dwLength != 0) 59 | // OutputPercent((int)((GetPosition()*100)/m_dwLength)); 60 | } 61 | 62 | void CTrackFile::OutputString(LPCTSTR lpsz) 63 | { 64 | if (m_pFrameWnd != NULL) 65 | { 66 | m_pFrameWnd->SetMessageText(lpsz); 67 | CWnd* pBarWnd = m_pFrameWnd->GetMessageBar(); 68 | if (pBarWnd != NULL) 69 | pBarWnd->UpdateWindow(); 70 | } 71 | } 72 | 73 | void CTrackFile::OutputPercent(int nPercentComplete) 74 | { 75 | if (m_pFrameWnd != NULL && m_nLastPercent != nPercentComplete) 76 | { 77 | m_nLastPercent = nPercentComplete; 78 | TCHAR buf[64]; 79 | int n = nPercentComplete; 80 | _stprintf_s(buf, 64, (n==100) ? m_strWait : m_strComplete, n); 81 | OutputString(buf); 82 | } 83 | } 84 | 85 | COEMFile::COEMFile(CFrameWnd* pWnd) : CTrackFile(pWnd) 86 | { 87 | } 88 | 89 | UINT COEMFile::Read(void FAR* lpBuf, UINT nCount) 90 | { 91 | UINT n = CTrackFile::Read(lpBuf, nCount); 92 | OemToCharBuffA((const char*)lpBuf, (char*)lpBuf, n); 93 | return n; 94 | } 95 | 96 | void COEMFile::Write(const void FAR* lpBuf, UINT nCount) 97 | { 98 | CharToOemBuffA((const char*)lpBuf, (char*)lpBuf, nCount); 99 | CTrackFile::Write(lpBuf, nCount); 100 | } 101 | 102 | #ifdef CONVERTERS 103 | 104 | HGLOBAL CConverter::StringToHGLOBAL(LPCSTR pstr) 105 | { 106 | HGLOBAL hMem = NULL; 107 | if (pstr != NULL) 108 | { 109 | hMem = GlobalAlloc(GHND, (lstrlenA(pstr)*2)+1); 110 | char* p = (char*) GlobalLock(hMem); 111 | ASSERT(p != NULL); 112 | if (p != NULL) 113 | strcpy_s(p, (lstrlenA(pstr)*2)+1, pstr); 114 | GlobalUnlock(hMem); 115 | } 116 | return hMem; 117 | } 118 | 119 | CConverter::CConverter(LPCSTR pszLibName, CFrameWnd* pWnd) : CTrackFile(pWnd) 120 | { 121 | USES_CONVERSION; 122 | m_hBuff = NULL; 123 | m_pBuf = NULL; 124 | m_nBytesAvail = 0; 125 | m_nBytesWritten = 0; 126 | m_nPercent = 0; 127 | m_hEventFile = NULL; 128 | m_hEventConv = NULL; 129 | m_bDone = TRUE; 130 | m_bConvErr = FALSE; 131 | m_hFileName = NULL; 132 | OFSTRUCT ofs; 133 | if (OpenFile(pszLibName, &ofs, OF_EXIST) == HFILE_ERROR) 134 | { 135 | m_hLibCnv = NULL; 136 | return; 137 | } 138 | m_hLibCnv = LoadLibraryA(pszLibName); 139 | if (m_hLibCnv < (HINSTANCE)HINSTANCE_ERROR) 140 | m_hLibCnv = NULL; 141 | else 142 | { 143 | LoadFunctions(); 144 | ASSERT(m_pInitConverter != NULL); 145 | if (m_pInitConverter != NULL) 146 | { 147 | CString str = AfxGetAppName(); 148 | str.MakeUpper(); 149 | VERIFY(m_pInitConverter(AfxGetMainWnd()->GetSafeHwnd(), T2CA(str))); 150 | } 151 | } 152 | } 153 | 154 | CConverter::CConverter(CFrameWnd* pWnd) : CTrackFile(pWnd) 155 | { 156 | m_pInitConverter = NULL; 157 | m_pIsFormatCorrect = NULL; 158 | m_pForeignToRtf = NULL; 159 | m_pRtfToForeign = NULL; 160 | m_bConvErr = FALSE; 161 | m_hFileName = NULL; 162 | } 163 | 164 | CConverter::~CConverter() 165 | { 166 | if (!m_bDone) // converter thread hasn't exited 167 | { 168 | WaitForConverter(); 169 | m_nBytesAvail = 0; 170 | VERIFY(ResetEvent(m_hEventFile)); 171 | m_nBytesAvail = 0; 172 | SetEvent(m_hEventConv); 173 | WaitForConverter();// wait for DoConversion exit 174 | VERIFY(ResetEvent(m_hEventFile)); 175 | } 176 | 177 | if (m_hEventFile != NULL) 178 | VERIFY(CloseHandle(m_hEventFile)); 179 | if (m_hEventConv != NULL) 180 | VERIFY(CloseHandle(m_hEventConv)); 181 | if (m_hLibCnv != NULL) 182 | FreeLibrary(m_hLibCnv); 183 | if (m_hFileName != NULL) 184 | GlobalFree(m_hFileName); 185 | } 186 | 187 | void CConverter::WaitForConverter() 188 | { 189 | // while event not signalled -- process messages 190 | while (MsgWaitForMultipleObjects(1, &m_hEventFile, FALSE, INFINITE, 191 | QS_SENDMESSAGE) != WAIT_OBJECT_0) 192 | { 193 | MSG msg; 194 | PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE); 195 | } 196 | } 197 | 198 | void CConverter::WaitForBuffer() 199 | { 200 | // while event not signalled -- process messages 201 | while (MsgWaitForMultipleObjects(1, &m_hEventConv, FALSE, INFINITE, 202 | QS_SENDMESSAGE) != WAIT_OBJECT_0) 203 | { 204 | MSG msg; 205 | PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE); 206 | } 207 | } 208 | 209 | UINT CConverter::ConverterThread(LPVOID) 210 | { 211 | ENSURE(m_pThis != NULL); 212 | 213 | HRESULT hRes = OleInitialize(NULL); 214 | ASSERT(hRes == S_OK || hRes == S_FALSE); 215 | m_pThis->DoConversion(); 216 | OleUninitialize(); 217 | 218 | return 0; 219 | } 220 | 221 | BOOL CConverter::IsFormatCorrect(LPCTSTR pszFileName) 222 | { 223 | USES_CONVERSION; 224 | int nRet; 225 | if (m_hLibCnv == NULL || m_pIsFormatCorrect == NULL) 226 | return FALSE; 227 | 228 | char buf[_MAX_PATH]; 229 | strcpy_s(buf, MAX_PATH, T2CA(pszFileName)); 230 | 231 | CharToOemA(buf, buf); 232 | 233 | HGLOBAL hFileName = StringToHGLOBAL(buf); 234 | HGLOBAL hDesc = GlobalAlloc(GHND, 256); 235 | ASSERT(hDesc != NULL); 236 | nRet = m_pIsFormatCorrect(hFileName, hDesc); 237 | GlobalFree(hDesc); 238 | GlobalFree(hFileName); 239 | return (nRet == 1) ? TRUE : FALSE; 240 | } 241 | 242 | // static callback function 243 | int CALLBACK CConverter::WriteOutStatic(int cch, int nPercentComplete) 244 | { 245 | ENSURE(m_pThis != NULL); 246 | return m_pThis->WriteOut(cch, nPercentComplete); 247 | } 248 | 249 | int CALLBACK CConverter::WriteOut(int cch, int nPercentComplete) 250 | { 251 | ASSERT(m_hBuff != NULL); 252 | m_nPercent = nPercentComplete; 253 | if (m_hBuff == NULL) 254 | return -9; 255 | if (cch != 0) 256 | { 257 | WaitForBuffer(); 258 | VERIFY(ResetEvent(m_hEventConv)); 259 | m_nBytesAvail = cch; 260 | SetEvent(m_hEventFile); 261 | WaitForBuffer(); 262 | } 263 | return 0; //everything OK 264 | } 265 | 266 | int CALLBACK CConverter::ReadInStatic(int /*flags*/, int nPercentComplete) 267 | { 268 | ENSURE(m_pThis != NULL); 269 | return m_pThis->ReadIn(nPercentComplete); 270 | } 271 | 272 | int CALLBACK CConverter::ReadIn(int /*nPercentComplete*/) 273 | { 274 | ASSERT(m_hBuff != NULL); 275 | if (m_hBuff == NULL) 276 | return -8; 277 | 278 | SetEvent(m_hEventFile); 279 | WaitForBuffer(); 280 | VERIFY(ResetEvent(m_hEventConv)); 281 | 282 | return m_nBytesAvail; 283 | } 284 | 285 | BOOL CConverter::DoConversion() 286 | { 287 | USES_CONVERSION; 288 | m_nLastPercent = -1; 289 | // m_dwLength = 0; // prevent Read/Write from displaying 290 | m_nPercent = 0; 291 | 292 | ASSERT(m_hBuff != NULL); 293 | ASSERT(m_pThis != NULL); 294 | HGLOBAL hDesc = StringToHGLOBAL(""); 295 | HGLOBAL hSubset = StringToHGLOBAL(""); 296 | 297 | int nRet = 0; 298 | if (m_bForeignToRtf) 299 | { 300 | ASSERT(m_pForeignToRtf != NULL); 301 | ASSERT(m_hFileName != NULL); 302 | nRet = m_pForeignToRtf(m_hFileName, NULL, m_hBuff, hDesc, hSubset, 303 | (LPFNOUT)WriteOutStatic); 304 | // wait for next CConverter::Read to come through 305 | WaitForBuffer(); 306 | VERIFY(ResetEvent(m_hEventConv)); 307 | } 308 | else if (!m_bForeignToRtf) 309 | { 310 | ASSERT(m_pRtfToForeign != NULL); 311 | ASSERT(m_hFileName != NULL); 312 | nRet = m_pRtfToForeign(m_hFileName, NULL, m_hBuff, hDesc, 313 | (LPFNIN)ReadInStatic); 314 | // don't need to wait for m_hEventConv 315 | } 316 | 317 | GlobalFree(hDesc); 318 | GlobalFree(hSubset); 319 | if (m_pBuf != NULL) 320 | GlobalUnlock(m_hBuff); 321 | GlobalFree(m_hBuff); 322 | 323 | if (nRet != 0) 324 | m_bConvErr = TRUE; 325 | 326 | m_bDone = TRUE; 327 | m_nPercent = 100; 328 | m_nLastPercent = -1; 329 | 330 | SetEvent(m_hEventFile); 331 | 332 | return (nRet == 0); 333 | } 334 | 335 | void CConverter::LoadFunctions() 336 | { 337 | m_pInitConverter = (PINITCONVERTER)GetProcAddress(m_hLibCnv, "InitConverter32"); 338 | m_pIsFormatCorrect = (PISFORMATCORRECT)GetProcAddress(m_hLibCnv, "IsFormatCorrect32"); 339 | m_pForeignToRtf = (PFOREIGNTORTF)GetProcAddress(m_hLibCnv, "ForeignToRtf32"); 340 | m_pRtfToForeign = (PRTFTOFOREIGN)GetProcAddress(m_hLibCnv, "RtfToForeign32"); 341 | } 342 | #endif 343 | 344 | /////////////////////////////////////////////////////////////////////////////// 345 | 346 | BOOL CConverter::Open(LPCTSTR pszFileName, UINT nOpenFlags, 347 | CFileException* pException) 348 | { 349 | USES_CONVERSION; 350 | // we convert to oem and back because of the following case 351 | // test(c).txt becomes testc.txt in OEM and stays testc.txt to Ansi 352 | char buf[_MAX_PATH]; 353 | strncpy_s(buf, _MAX_PATH, T2CA(pszFileName), _TRUNCATE); 354 | buf[_MAX_PATH-1] = NULL; 355 | int nLen = (int)strlen(buf); 356 | if(nLen >= _MAX_PATH) 357 | { 358 | nLen = _MAX_PATH - 1; 359 | } 360 | 361 | CharToOemBuffA(buf, buf, nLen); 362 | OemToCharBuffA(buf, buf, nLen); 363 | 364 | LPTSTR lpszFileNameT = A2T(buf); 365 | 366 | // let's make sure we could do what is wanted directly even though we aren't 367 | m_bCloseOnDelete = FALSE; 368 | m_hFile = (HANDLE)hFileNull; 369 | 370 | BOOL bOpen = CFile::Open(lpszFileNameT, nOpenFlags, pException); 371 | CFile::Close(); 372 | if (!bOpen) 373 | return FALSE; 374 | 375 | m_bForeignToRtf = !(nOpenFlags & (CFile::modeReadWrite | CFile::modeWrite)); 376 | 377 | // check for reading empty file 378 | if (m_bForeignToRtf) 379 | { 380 | CFileStatus stat; 381 | if (CFile::GetStatus(lpszFileNameT, stat) && stat.m_size == 0) 382 | return TRUE; 383 | } 384 | 385 | //set security attributes to inherit handle 386 | SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; 387 | //create the events 388 | m_hEventFile = CreateEvent(&sa, TRUE, FALSE, NULL); 389 | m_hEventConv = CreateEvent(&sa, TRUE, FALSE, NULL); 390 | //create the converter thread and create the events 391 | 392 | CharToOemA(buf, buf); 393 | ASSERT(m_hFileName == NULL); 394 | m_hFileName = StringToHGLOBAL(buf); 395 | 396 | m_pThis = this; 397 | m_bDone = FALSE; 398 | m_hBuff = GlobalAlloc(GHND, BUFFSIZE); 399 | ASSERT(m_hBuff != NULL); 400 | 401 | AfxBeginThread(ConverterThread, this, THREAD_PRIORITY_NORMAL, 0, 0, &sa); 402 | 403 | return TRUE; 404 | } 405 | 406 | // m_hEventConv -- the main thread signals this event when ready for more data 407 | // m_hEventFile -- the converter signals this event when data is ready 408 | 409 | UINT CConverter::Read(void FAR* lpBuf, UINT nCount) 410 | { 411 | ASSERT(m_bForeignToRtf); 412 | if (m_bDone) 413 | return 0; 414 | // if converter is done 415 | int cch = nCount; 416 | BYTE* pBuf = (BYTE*)lpBuf; 417 | while (cch != 0) 418 | { 419 | if (m_nBytesAvail == 0) 420 | { 421 | if (m_pBuf != NULL) 422 | GlobalUnlock(m_hBuff); 423 | m_pBuf = NULL; 424 | SetEvent(m_hEventConv); 425 | WaitForConverter(); 426 | VERIFY(ResetEvent(m_hEventFile)); 427 | if (m_bConvErr) 428 | { 429 | #if _MFC_VER >= 0x700 430 | AfxThrowFileException(CFileException::genericException); 431 | #else 432 | AfxThrowFileException(CFileException::generic); 433 | #endif 434 | } 435 | if (m_bDone) 436 | return nCount - cch; 437 | m_pBuf = (BYTE*)GlobalLock(m_hBuff); 438 | ASSERT(m_pBuf != NULL); 439 | } 440 | int nBytes = min(cch, m_nBytesAvail); 441 | memcpy_s(pBuf, nCount, m_pBuf, nBytes); 442 | pBuf += nBytes; 443 | m_pBuf += nBytes; 444 | m_nBytesAvail -= nBytes; 445 | cch -= nBytes; 446 | OutputPercent(m_nPercent); 447 | } 448 | return nCount - cch; 449 | } 450 | 451 | void CConverter::Write(const void FAR* lpBuf, UINT nCount) 452 | { 453 | ASSERT(!m_bForeignToRtf); 454 | 455 | m_nBytesWritten += nCount; 456 | while (nCount != 0) 457 | { 458 | WaitForConverter(); 459 | VERIFY(ResetEvent(m_hEventFile)); 460 | if (m_bConvErr) 461 | { 462 | #if _MFC_VER >= 0x700 463 | AfxThrowFileException(CFileException::genericException); 464 | #else 465 | AfxThrowFileException(CFileException::generic); 466 | #endif 467 | } 468 | m_nBytesAvail = min(nCount, BUFFSIZE); 469 | nCount -= m_nBytesAvail; 470 | BYTE* pBuf = (BYTE*)GlobalLock(m_hBuff); 471 | ASSERT(pBuf != NULL); 472 | memcpy(pBuf, lpBuf, m_nBytesAvail); 473 | GlobalUnlock(m_hBuff); 474 | SetEvent(m_hEventConv); 475 | } 476 | OutputString(m_strSaving); 477 | } 478 | 479 | ULONGLONG CConverter::Seek(LONGLONG lOff, UINT nFrom) 480 | { 481 | if (lOff != 0 && nFrom != current) 482 | AfxThrowNotSupportedException(); 483 | return 0; 484 | } 485 | 486 | WP_FILE_SIZE CConverter::GetPosition() const 487 | { 488 | return 0; 489 | } 490 | 491 | void CConverter::Flush() 492 | { 493 | } 494 | 495 | void CConverter::Close() 496 | { 497 | } 498 | 499 | void CConverter::Abort() 500 | { 501 | } 502 | 503 | WP_FILE_SIZE CConverter::GetLength() const 504 | { 505 | ASSERT_VALID(this); 506 | return 1; 507 | } 508 | 509 | CFile* CConverter::Duplicate() const 510 | { 511 | AfxThrowNotSupportedException(); 512 | } 513 | 514 | void CConverter::LockRange(ULONGLONG, ULONGLONG) 515 | { 516 | AfxThrowNotSupportedException(); 517 | } 518 | 519 | void CConverter::UnlockRange(ULONGLONG, ULONGLONG) 520 | { 521 | AfxThrowNotSupportedException(); 522 | } 523 | 524 | void CConverter::SetLength(ULONGLONG) 525 | { 526 | AfxThrowNotSupportedException(); 527 | } 528 | 529 | // vim:sw=4:ts=4:noet: 530 | -------------------------------------------------------------------------------- /src/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 WP_FILE_SIZE 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 WP_FILE_SIZE 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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/res/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/font.bmp -------------------------------------------------------------------------------- /src/res/formatba.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/formatba.bmp -------------------------------------------------------------------------------- /src/res/formatbg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/formatbg.bmp -------------------------------------------------------------------------------- /src/res/main1.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/main1.bmp -------------------------------------------------------------------------------- /src/res/main1b.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/main1b.bmp -------------------------------------------------------------------------------- /src/res/mainfrm.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/mainfrm.bmp -------------------------------------------------------------------------------- /src/res/mainfrmb.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/mainfrmb.bmp -------------------------------------------------------------------------------- /src/res/rtfdoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rtfdoc.ico -------------------------------------------------------------------------------- /src/res/rulerbl.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulerbl.bmp -------------------------------------------------------------------------------- /src/res/rulerblm.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulerblm.bmp -------------------------------------------------------------------------------- /src/res/rulerdo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulerdo.bmp -------------------------------------------------------------------------------- /src/res/rulerdom.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulerdom.bmp -------------------------------------------------------------------------------- /src/res/rulerta.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulerta.bmp -------------------------------------------------------------------------------- /src/res/rulertam.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulertam.bmp -------------------------------------------------------------------------------- /src/res/rulerup.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulerup.bmp -------------------------------------------------------------------------------- /src/res/rulerupm.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/rulerupm.bmp -------------------------------------------------------------------------------- /src/res/srvr.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/srvr.bmp -------------------------------------------------------------------------------- /src/res/srvrbig.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/srvrbig.bmp -------------------------------------------------------------------------------- /src/res/textdoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/textdoc.ico -------------------------------------------------------------------------------- /src/res/wordp48.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/wordp48.bmp -------------------------------------------------------------------------------- /src/res/wordpad.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/wordpad.ico -------------------------------------------------------------------------------- /src/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 | 15 | CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "wordpad.manifest" 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // 19 | // Data 20 | // 21 | 22 | IDR_LICENSE_TEXT 10 "..\\license.txt" 23 | 24 | -------------------------------------------------------------------------------- /src/res/write.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/res/write.ico -------------------------------------------------------------------------------- /src/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ 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 IDD_ABOUT 161 98 | #define IDB_BITMAP48 162 99 | #define IDB_BITMAP_PRINTER 163 100 | #define IDS_FINISHED_SEARCH 164 101 | #define IDC_FONTNAME 165 102 | #define IDI_ICON_TEXT 165 103 | #define IDC_FONTSIZE 166 104 | #define IDS_TITLE_FORMATBAR 167 105 | #define IDB_PRINTER 167 106 | #define IDB_FONTTYPE 167 107 | #define IDS_TITLE_TOOLBAR 168 108 | #define IDS_INCH1_ABBREV 169 109 | #define IDS_INCH2_ABBREV 170 110 | #define IDS_INCH3_ABBREV 171 111 | #define IDS_INCH4_ABBREV 172 112 | #define IDR_LICENSE_TEXT 172 113 | #define IDS_CM_ABBREV 173 114 | #define IDS_POINT_ABBREV 174 115 | #define IDS_PICA_ABBREV 175 116 | #define IDS_NOMORETABS 176 117 | #define IDS_MAPI_FAIL 177 118 | #define IDS_ERRSPACE 178 119 | #define IDS_CANT_LOAD 179 120 | #define IDS_TOOMANYFILES 180 121 | #define IDS_DIRFULL 181 122 | #define IDS_SHAREVIOLATION 182 123 | #define IDS_TEXT_OPTIONS 183 124 | #define IDS_RTF_OPTIONS 184 125 | #define IDS_WORD6_OPTIONS 185 126 | #define IDS_OPTIONS 186 127 | #define IDS_WRITE_OPTIONS 187 128 | #define IDS_EMBEDDED_OPTIONS 188 129 | #define IDS_TEXT_DOCUMENT 189 130 | #define IDS_RTF_DOCUMENT 190 131 | #define IDS_WORD6_DOCUMENT 191 132 | #define IDS_WRITEPROTECT 192 133 | #define IDC_EDIT_LEFT 1000 134 | #define IDC_EDIT_RIGHT 1001 135 | #define IDC_EDIT_FIRST_LINE 1002 136 | #define IDC_BUTTON_SET 1005 137 | #define IDC_EDIT_BM 1005 138 | #define IDC_BUTTON_CLEAR 1006 139 | #define IDC_EDIT_LM 1006 140 | #define IDC_BUTTON_CLEARALL 1007 141 | #define IDC_EDIT_RM 1007 142 | #define IDC_STATIC_HEADING 1009 143 | #define IDC_COMBO_WRAP 1011 144 | #define IDC_COMBO_UNITS 1012 145 | #define IDC_EDIT_TM 1016 146 | #define IDC_TEXT_ALIGNMENT 1017 147 | #define IDC_LISTDIALOG_LIST 1018 148 | #define IDC_DATEDIALOG_LIST 1018 149 | #define IDC_COMBO1 1019 150 | #define IDC_TEXT_WRAP 1020 151 | #define IDC_TEXT_UNITS 1021 152 | #define IDC_BOX 1022 153 | #define IDC_BIGICON 1023 154 | #define IDC_UNITS_IN 1024 155 | #define IDC_UNITS_CM 1025 156 | #define IDC_WRAP_RULER 1025 157 | #define IDC_UNITS_PT 1026 158 | #define IDC_WRAP_WINDOW 1026 159 | #define IDC_UNITS_PI 1027 160 | #define IDC_WRAP_NONE 1027 161 | #define IDC_CHECK_TOOLBAR 1028 162 | #define IDC_CHECK_FORMATBAR 1029 163 | #define IDC_WORDSEL 1029 164 | #define IDC_CHECK_RULERBAR 1030 165 | #define IDC_CHECK_STATUSBAR 1031 166 | #define IDC_BOXT 1032 167 | #define IDC_CHECK_PAGEBREAK 1033 168 | #define IDC_EDIT_BEFORE 1035 169 | #define IDC_EDIT_AFTER 1036 170 | #define IDC_SPIN_BEFORE 1038 171 | #define IDC_SPIN_AFTER 1039 172 | #define IDC_LICENSE_TEXT 1041 173 | #define ID_CANCEL_EDIT_CNTR 32768 174 | #define ID_CANCEL_EDIT_SRVR 32769 175 | #define ID_PAGE_SETUP 32771 176 | #define ID_VIEW_OPTIONS 32776 177 | #define ID_INSERT_BULLET 32777 178 | #define ID_INSERT_DATE_TIME 32778 179 | #define ID_FORMAT_PARAGRAPH 32780 180 | #define ID_FORMAT_TABS 32781 181 | #define ID_COLOR0 32782 182 | #define ID_COLOR1 32783 183 | #define ID_COLOR2 32784 184 | #define ID_COLOR3 32785 185 | #define ID_COLOR4 32786 186 | #define ID_COLOR5 32787 187 | #define ID_COLOR6 32788 188 | #define ID_COLOR7 32789 189 | #define ID_COLOR8 32790 190 | #define ID_COLOR9 32791 191 | #define ID_COLOR10 32792 192 | #define ID_COLOR11 32793 193 | #define ID_COLOR12 32794 194 | #define ID_COLOR13 32795 195 | #define ID_COLOR14 32796 196 | #define ID_COLOR15 32797 197 | #define ID_COLOR16 32798 198 | #define ID_CHAR_BOLD 32799 199 | #define ID_CHAR_ITALIC 32800 200 | #define ID_CHAR_COLOR 32801 201 | #define ID_CHAR_UNDERLINE 32802 202 | #define ID_PARA_LEFT 32803 203 | #define ID_PARA_CENTER 32804 204 | #define ID_PARA_RIGHT 32805 205 | #define ID_PEN_PERIOD 32807 206 | #define ID_PEN_SPACE 32808 207 | #define ID_PEN_BACKSPACE 32809 208 | #define ID_PEN_NEWLINE 32810 209 | #ifndef ID_OLE_VERB_POPUP 210 | #define ID_OLE_VERB_POPUP 32811 211 | #endif 212 | #define ID_PEN_TOGGLE 32812 213 | #define ID_PEN_LENS 32813 214 | #define ID_PEN_TAB 32814 215 | #define ID_VIEW_FORMATBAR 59396 216 | #define ID_VIEW_RULER 59397 217 | 218 | // Next default values for new objects 219 | // 220 | #ifdef APSTUDIO_INVOKED 221 | #ifndef APSTUDIO_READONLY_SYMBOLS 222 | #define _APS_3D_CONTROLS 1 223 | #define _APS_NEXT_RESOURCE_VALUE 173 224 | #define _APS_NEXT_COMMAND_VALUE 32816 225 | #define _APS_NEXT_CONTROL_VALUE 1043 226 | #define _APS_NEXT_SYMED_VALUE 105 227 | #endif 228 | #endif 229 | -------------------------------------------------------------------------------- /src/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 WP_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(WP_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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | // CSplash dialog 14 | 15 | #pragma warning(push) 16 | // Disable warning on Create. 17 | #pragma warning(disable : 4264) 18 | #pragma warning(disable : 4263) 19 | class CSplashWnd : public CDialog 20 | { 21 | private: 22 | using CDialog::Create; 23 | 24 | // Construction 25 | public: 26 | BOOL Create(CWnd* pParent = NULL); 27 | 28 | // Dialog Data 29 | //{{AFX_DATA(CSplashWnd) 30 | enum { IDD = IDD_SPLASH }; 31 | // NOTE: the ClassWizard will add data members here 32 | //}}AFX_DATA 33 | 34 | // Implementation 35 | protected: 36 | CBigIcon m_icon; // self-draw button 37 | 38 | // Generated message map functions 39 | //{{AFX_MSG(CSplashWnd) 40 | virtual BOOL OnInitDialog(); 41 | //}}AFX_MSG 42 | }; 43 | #pragma warning(pop) 44 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | #define _CRT_NON_CONFORMING_SWPRINTFS 1 20 | #define _CRT_SECURE_NO_WARNINGS 1 21 | 22 | #define _UNICODE 1 23 | #define UNICODE 1 24 | 25 | #ifdef _MSC_VER 26 | #if _MSC_VER >= 1700 27 | #define WINVER 0x601 28 | #elif _MSC_VER >= 1600 29 | #define WINVER 0x501 30 | #elif _MSC_VER >= 1500 31 | #define WINVER 0x500 32 | #else 33 | #define WINVER 0x400 34 | #endif 35 | 36 | #if _MSC_VER >= 1600 37 | #pragma warning(disable: 4996) // Function declared deprecated 38 | #endif 39 | #endif 40 | 41 | #define CONVERTERS 42 | 43 | #include // MFC core and standard components 44 | #include // MFC extensions 45 | #include // MFC OLE classes 46 | #include // MFC OLE dialog classes 47 | #include 48 | #include 49 | #include 50 | 51 | #define HORZ_TEXTOFFSET 15 52 | #define VERT_TEXTOFFSET 5 53 | 54 | #if !defined(_WIN64) && defined(_MSC_VER) && _MSC_VER < 1300 55 | typedef INT WP_INT_PTR; 56 | typedef LONG LONG_PTR; 57 | typedef DWORD DWORD_PTR; 58 | #else 59 | typedef INT_PTR WP_INT_PTR; 60 | #endif 61 | 62 | #if _MFC_VER >= 0x700 63 | typedef CHARFORMAT2 WP_CHARFORMAT; 64 | typedef PARAFORMAT2 WP_PARAFORMAT; 65 | typedef ULONGLONG WP_FILE_SIZE; 66 | #else 67 | typedef CHARFORMAT WP_CHARFORMAT; 68 | typedef PARAFORMAT WP_PARAFORMAT; 69 | typedef DWORD WP_FILE_SIZE; 70 | #endif 71 | 72 | #ifndef ENSURE 73 | #define ENSURE(x) if (!(x)) ::AfxThrowMemoryException() 74 | #endif 75 | 76 | class CDisplayIC : public CDC 77 | { 78 | public: 79 | CDisplayIC() { CreateIC(_T("DISPLAY"), NULL, NULL, NULL); } 80 | }; 81 | 82 | struct CCharFormat : public WP_CHARFORMAT 83 | { 84 | CCharFormat() {cbSize = sizeof(WP_CHARFORMAT);} 85 | BOOL operator==(CCharFormat& cf); 86 | }; 87 | 88 | struct CParaFormat : public WP_PARAFORMAT 89 | { 90 | CParaFormat() {cbSize = sizeof(_paraformat);} 91 | BOOL operator==(WP_PARAFORMAT& pf); 92 | }; 93 | 94 | #include "doctype.h" 95 | #include "chicdial.h" 96 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 "bigicon.h" 18 | #include "splash.h" 19 | #include "about.h" 20 | #include "options.h" 21 | #include "afxtempl.h" 22 | 23 | #define WPM_BARSTATE WM_USER 24 | 25 | ///////////////////////////////////////////////////////////////////////////// 26 | // CWordPadApp: 27 | // See wordpad.cpp for the implementation of this class 28 | // 29 | 30 | class CWordPadCommandLineInfo : public CCommandLineInfo 31 | { 32 | public: 33 | CWordPadCommandLineInfo() {m_bForceTextMode = FALSE;} 34 | BOOL m_bForceTextMode; 35 | virtual void ParseParam(const char* pszParam,BOOL bFlag,BOOL bLast); 36 | }; 37 | 38 | class CWordPadApp : public CWinApp 39 | { 40 | public: 41 | CWordPadApp(); 42 | ~CWordPadApp(); 43 | 44 | //Attributes 45 | CWordPadCommandLineInfo cmdInfo; 46 | CDC m_dcScreen; 47 | LOGFONT m_lf; 48 | int m_nDefFont; 49 | static int m_nOpenMsg; 50 | static int m_nPrinterChangedMsg; 51 | CRect m_rectPageMargin; 52 | CRect m_rectInitialFrame; 53 | BOOL m_bMaximized; 54 | BOOL m_bPromptForType; 55 | BOOL m_bWin4; 56 | #ifndef _UNICODE 57 | BOOL m_bWin31; 58 | #endif 59 | BOOL m_bLargeIcons; 60 | BOOL m_bForceTextMode; 61 | BOOL m_bWordSel; 62 | BOOL m_bForceOEM; 63 | int m_nFilterIndex; 64 | int m_nNewDocType; 65 | CDocOptions m_optionsText; 66 | CDocOptions m_optionsRTF; 67 | CDocOptions m_optionsWord; //wrap to ruler 68 | CDocOptions m_optionsWrite; //wrap to ruler 69 | CDocOptions m_optionsIP; //wrap to ruler 70 | CDocOptions m_optionsNull; 71 | CList m_listPrinterNotify; 72 | 73 | BOOL IsDocOpen(LPCTSTR lpszFileName); 74 | 75 | // Get 76 | int GetUnits() {return m_nUnits;} 77 | int GetTPU() { return GetTPU(m_nUnits);} 78 | int GetTPU(int n) { return m_units[n].m_nTPU;} 79 | LPCTSTR GetAbbrev() { return m_units[m_nUnits].m_strAbbrev;} 80 | LPCTSTR GetAbbrev(int n) { return m_units[n].m_strAbbrev;} 81 | const CUnit& GetUnit() {return m_units[m_nUnits];} 82 | CDockState& GetDockState(LONG_PTR nDocType, BOOL bPrimary = TRUE); 83 | CDocOptions& GetDocOptions(LONG_PTR nDocType); 84 | 85 | // Set 86 | void SetUnits(int n) 87 | { ASSERT(n>=0 && n 2 | 3 | 4 | Wordpad 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/wordpad.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/wordpad.rc -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/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 | -------------------------------------------------------------------------------- /src/write32.wpc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malxau/wordpad/68511647ff702eaa8a5ccd909ef114feb0aa949e/src/write32.wpc --------------------------------------------------------------------------------