Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 1 | /* |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 2 | * Notepad (dialog.c) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 3 | * |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 4 | * Copyright 1998,99 Marcel Baur <mbaur@g26.ethz.ch> |
Sylvain Petreolle | eaa8df6 | 2002-03-20 22:55:46 +0000 | [diff] [blame] | 5 | * Copyright 2002 Sylvain Petreolle <spetreolle@yahoo.fr> |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 6 | * Copyright 2002 Andriy Palamarchuk |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 7 | * Copyright 2007 Rolf Kalbermatter |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 8 | * |
| 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Lesser General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2.1 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public |
| 20 | * License along with this library; if not, write to the Free Software |
Jonathan Ernst | 360a3f9 | 2006-05-18 14:49:52 +0200 | [diff] [blame] | 21 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 22 | */ |
| 23 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 24 | #define UNICODE |
| 25 | |
Ulrich Weigand | 97d05c8 | 2000-01-29 22:07:03 +0000 | [diff] [blame] | 26 | #include <assert.h> |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 27 | #include <stdio.h> |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 28 | #include <windows.h> |
| 29 | #include <commdlg.h> |
Mikołaj Zalewski | b0905ac | 2006-10-22 18:54:51 +0200 | [diff] [blame] | 30 | #include <shlwapi.h> |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 31 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 32 | #include "main.h" |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 33 | #include "dialog.h" |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 34 | |
Duane Clark | a60ee9c | 2006-07-16 16:20:30 -0700 | [diff] [blame] | 35 | #define SPACES_IN_TAB 8 |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 36 | #define PRINT_LEN_MAX 500 |
Duane Clark | a60ee9c | 2006-07-16 16:20:30 -0700 | [diff] [blame] | 37 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 38 | static const WCHAR helpfileW[] = { 'n','o','t','e','p','a','d','.','h','l','p',0 }; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 39 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 40 | static INT_PTR WINAPI DIALOG_PAGESETUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 41 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 42 | VOID ShowLastError(void) |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 43 | { |
| 44 | DWORD error = GetLastError(); |
| 45 | if (error != NO_ERROR) |
| 46 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 47 | LPWSTR lpMsgBuf; |
| 48 | WCHAR szTitle[MAX_STRING_LEN]; |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 49 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 50 | LoadString(Globals.hInstance, STRING_ERROR, szTitle, SIZEOF(szTitle)); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 51 | FormatMessage( |
| 52 | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, |
| 53 | NULL, error, 0, |
| 54 | (LPTSTR) &lpMsgBuf, 0, NULL); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 55 | MessageBox(NULL, lpMsgBuf, szTitle, MB_OK | MB_ICONERROR); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 56 | LocalFree(lpMsgBuf); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Sets the caption of the main window according to Globals.szFileTitle: |
Thomas Kho | 3ec165f | 2006-07-12 14:15:31 -0700 | [diff] [blame] | 62 | * Untitled - Notepad if no file is open |
| 63 | * filename - Notepad if a file is given |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 64 | */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 65 | static void UpdateWindowCaption(void) |
| 66 | { |
| 67 | WCHAR szCaption[MAX_STRING_LEN]; |
Thomas Kho | 3ec165f | 2006-07-12 14:15:31 -0700 | [diff] [blame] | 68 | WCHAR szNotepad[MAX_STRING_LEN]; |
| 69 | static const WCHAR hyphenW[] = { ' ','-',' ',0 }; |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 70 | |
Thomas Kho | 3ec165f | 2006-07-12 14:15:31 -0700 | [diff] [blame] | 71 | if (Globals.szFileTitle[0] != '\0') |
| 72 | lstrcpy(szCaption, Globals.szFileTitle); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 73 | else |
Thomas Kho | 3ec165f | 2006-07-12 14:15:31 -0700 | [diff] [blame] | 74 | LoadString(Globals.hInstance, STRING_UNTITLED, szCaption, SIZEOF(szCaption)); |
| 75 | |
| 76 | LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, SIZEOF(szNotepad)); |
| 77 | lstrcat(szCaption, hyphenW); |
| 78 | lstrcat(szCaption, szNotepad); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 79 | |
| 80 | SetWindowText(Globals.hMainWnd, szCaption); |
| 81 | } |
| 82 | |
Mikołaj Zalewski | b0905ac | 2006-10-22 18:54:51 +0200 | [diff] [blame] | 83 | int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCWSTR szString, DWORD dwFlags) |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 84 | { |
| 85 | WCHAR szMessage[MAX_STRING_LEN]; |
| 86 | WCHAR szResource[MAX_STRING_LEN]; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 87 | |
| 88 | /* Load and format szMessage */ |
Mikołaj Zalewski | b0905ac | 2006-10-22 18:54:51 +0200 | [diff] [blame] | 89 | LoadString(Globals.hInstance, formatId, szResource, SIZEOF(szResource)); |
| 90 | wnsprintf(szMessage, SIZEOF(szMessage), szResource, szString); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 91 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 92 | /* Load szCaption */ |
Mikołaj Zalewski | b0905ac | 2006-10-22 18:54:51 +0200 | [diff] [blame] | 93 | if ((dwFlags & MB_ICONMASK) == MB_ICONEXCLAMATION) |
| 94 | LoadString(Globals.hInstance, STRING_ERROR, szResource, SIZEOF(szResource)); |
| 95 | else |
| 96 | LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, SIZEOF(szResource)); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 97 | |
| 98 | /* Display Modal Dialog */ |
Mikołaj Zalewski | b0905ac | 2006-10-22 18:54:51 +0200 | [diff] [blame] | 99 | if (hParent == NULL) |
| 100 | hParent = Globals.hMainWnd; |
| 101 | return MessageBox(hParent, szMessage, szResource, dwFlags); |
| 102 | } |
| 103 | |
| 104 | static void AlertFileNotFound(LPCWSTR szFileName) |
| 105 | { |
| 106 | DIALOG_StringMsgBox(NULL, STRING_NOTFOUND, szFileName, MB_ICONEXCLAMATION|MB_OK); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 107 | } |
| 108 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 109 | static int AlertFileNotSaved(LPCWSTR szFileName) |
| 110 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 111 | WCHAR szUntitled[MAX_STRING_LEN]; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 112 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 113 | LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, SIZEOF(szUntitled)); |
Mikołaj Zalewski | b0905ac | 2006-10-22 18:54:51 +0200 | [diff] [blame] | 114 | return DIALOG_StringMsgBox(NULL, STRING_NOTSAVED, szFileName[0] ? szFileName : szUntitled, |
| 115 | MB_ICONQUESTION|MB_YESNOCANCEL); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 118 | /** |
| 119 | * Returns: |
| 120 | * TRUE - if file exists |
| 121 | * FALSE - if file does not exist |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 122 | */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 123 | BOOL FileExists(LPCWSTR szFilename) |
| 124 | { |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 125 | WIN32_FIND_DATA entry; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 126 | HANDLE hFile; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 127 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 128 | hFile = FindFirstFile(szFilename, &entry); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 129 | FindClose(hFile); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 130 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 131 | return (hFile != INVALID_HANDLE_VALUE); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 134 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 135 | static VOID DoSaveFile(VOID) |
| 136 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 137 | HANDLE hFile; |
| 138 | DWORD dwNumWrite; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 139 | LPSTR pTemp; |
| 140 | DWORD size; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 141 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 142 | hFile = CreateFile(Globals.szFileName, GENERIC_WRITE, FILE_SHARE_WRITE, |
| 143 | NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); |
| 144 | if(hFile == INVALID_HANDLE_VALUE) |
| 145 | { |
| 146 | ShowLastError(); |
| 147 | return; |
| 148 | } |
| 149 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 150 | size = GetWindowTextLengthA(Globals.hEdit) + 1; |
| 151 | pTemp = HeapAlloc(GetProcessHeap(), 0, size); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 152 | if (!pTemp) |
| 153 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 154 | CloseHandle(hFile); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 155 | ShowLastError(); |
| 156 | return; |
| 157 | } |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 158 | size = GetWindowTextA(Globals.hEdit, pTemp, size); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 159 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 160 | if (!WriteFile(hFile, pTemp, size, &dwNumWrite, NULL)) |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 161 | ShowLastError(); |
Juan Lang | e55b943 | 2004-12-06 16:14:44 +0000 | [diff] [blame] | 162 | else |
| 163 | SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 164 | |
Jan Nieuwenhuizen | 137e54d | 2005-10-26 10:07:05 +0000 | [diff] [blame] | 165 | SetEndOfFile(hFile); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 166 | CloseHandle(hFile); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 167 | HeapFree(GetProcessHeap(), 0, pTemp); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 168 | } |
| 169 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 170 | /** |
| 171 | * Returns: |
| 172 | * TRUE - User agreed to close (both save/don't save) |
| 173 | * FALSE - User cancelled close by selecting "Cancel" |
| 174 | */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 175 | BOOL DoCloseFile(void) |
| 176 | { |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 177 | int nResult; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 178 | static const WCHAR empty_strW[] = { 0 }; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 179 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 180 | if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0)) |
| 181 | { |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 182 | /* prompt user to save changes */ |
| 183 | nResult = AlertFileNotSaved(Globals.szFileName); |
| 184 | switch (nResult) { |
Hirofumi Katayama | 32b6a1a | 2008-09-09 12:44:36 +0900 | [diff] [blame^] | 185 | case IDYES: return DIALOG_FileSave(); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 186 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 187 | case IDNO: break; |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 188 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 189 | case IDCANCEL: return(FALSE); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 190 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 191 | default: return(FALSE); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 192 | } /* switch */ |
| 193 | } /* if */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 194 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 195 | SetFileName(empty_strW); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 196 | |
| 197 | UpdateWindowCaption(); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 198 | return(TRUE); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 202 | void DoOpenFile(LPCWSTR szFileName) |
| 203 | { |
Kevin Koltzau | 868a2b04 | 2005-05-07 12:14:05 +0000 | [diff] [blame] | 204 | static const WCHAR dotlog[] = { '.','L','O','G',0 }; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 205 | HANDLE hFile; |
| 206 | LPSTR pTemp; |
| 207 | DWORD size; |
| 208 | DWORD dwNumRead; |
Kevin Koltzau | 868a2b04 | 2005-05-07 12:14:05 +0000 | [diff] [blame] | 209 | WCHAR log[5]; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 210 | |
Marcus Meissner | 73458b0 | 1998-12-26 12:54:29 +0000 | [diff] [blame] | 211 | /* Close any files and prompt to save changes */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 212 | if (!DoCloseFile()) |
| 213 | return; |
| 214 | |
| 215 | hFile = CreateFile(szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, |
| 216 | OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); |
| 217 | if(hFile == INVALID_HANDLE_VALUE) |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 218 | { |
Dmitry Timoshkov | 4ea5fce | 2007-08-31 16:02:01 +0900 | [diff] [blame] | 219 | AlertFileNotFound(szFileName); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 220 | return; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 221 | } |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 222 | |
| 223 | size = GetFileSize(hFile, NULL); |
Alexandre Julliard | 2aa8a83 | 2003-10-16 19:31:11 +0000 | [diff] [blame] | 224 | if (size == INVALID_FILE_SIZE) |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 225 | { |
| 226 | CloseHandle(hFile); |
| 227 | ShowLastError(); |
| 228 | return; |
| 229 | } |
| 230 | size++; |
| 231 | |
| 232 | pTemp = HeapAlloc(GetProcessHeap(), 0, size); |
| 233 | if (!pTemp) |
| 234 | { |
| 235 | CloseHandle(hFile); |
| 236 | ShowLastError(); |
| 237 | return; |
| 238 | } |
| 239 | |
| 240 | if (!ReadFile(hFile, pTemp, size, &dwNumRead, NULL)) |
| 241 | { |
| 242 | CloseHandle(hFile); |
| 243 | HeapFree(GetProcessHeap(), 0, pTemp); |
| 244 | ShowLastError(); |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | CloseHandle(hFile); |
| 249 | pTemp[dwNumRead] = 0; |
| 250 | |
Alexander Nicolaysen Sørnes | d50e2df | 2008-07-13 14:08:58 +0200 | [diff] [blame] | 251 | if((size -1) >= 2 && (BYTE)pTemp[0] == 0xff && (BYTE)pTemp[1] == 0xfe) |
| 252 | SetWindowTextW(Globals.hEdit, (LPWSTR)pTemp + 1); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 253 | else |
| 254 | SetWindowTextA(Globals.hEdit, pTemp); |
| 255 | |
| 256 | HeapFree(GetProcessHeap(), 0, pTemp); |
| 257 | |
| 258 | SendMessage(Globals.hEdit, EM_SETMODIFY, FALSE, 0); |
| 259 | SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0); |
| 260 | SetFocus(Globals.hEdit); |
Kevin Koltzau | 868a2b04 | 2005-05-07 12:14:05 +0000 | [diff] [blame] | 261 | |
James Hawkins | e4c1227 | 2008-02-29 22:37:21 -0600 | [diff] [blame] | 262 | /* If the file starts with .LOG, add a time/date at the end and set cursor after */ |
Kevin Koltzau | 868a2b04 | 2005-05-07 12:14:05 +0000 | [diff] [blame] | 263 | if (GetWindowTextW(Globals.hEdit, log, sizeof(log)/sizeof(log[0])) && !lstrcmp(log, dotlog)) |
| 264 | { |
| 265 | static const WCHAR lfW[] = { '\r','\n',0 }; |
| 266 | SendMessage(Globals.hEdit, EM_SETSEL, GetWindowTextLength(Globals.hEdit), -1); |
| 267 | SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW); |
| 268 | DIALOG_EditTimeDate(); |
| 269 | SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)lfW); |
| 270 | } |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 271 | |
| 272 | SetFileName(szFileName); |
| 273 | UpdateWindowCaption(); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 276 | VOID DIALOG_FileNew(VOID) |
| 277 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 278 | static const WCHAR empty_strW[] = { 0 }; |
| 279 | |
Francois Gouget | 8a18e0e | 2008-04-07 13:01:02 +0200 | [diff] [blame] | 280 | /* Close any files and prompt to save changes */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 281 | if (DoCloseFile()) { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 282 | SetWindowText(Globals.hEdit, empty_strW); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 283 | SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0); |
| 284 | SetFocus(Globals.hEdit); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 285 | } |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | VOID DIALOG_FileOpen(VOID) |
| 289 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 290 | OPENFILENAME openfilename; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 291 | WCHAR szPath[MAX_PATH]; |
| 292 | WCHAR szDir[MAX_PATH]; |
| 293 | static const WCHAR szDefaultExt[] = { 't','x','t',0 }; |
| 294 | static const WCHAR txt_files[] = { '*','.','t','x','t',0 }; |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 295 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 296 | ZeroMemory(&openfilename, sizeof(openfilename)); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 297 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 298 | GetCurrentDirectory(SIZEOF(szDir), szDir); |
| 299 | lstrcpy(szPath, txt_files); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 300 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 301 | openfilename.lStructSize = sizeof(openfilename); |
| 302 | openfilename.hwndOwner = Globals.hMainWnd; |
| 303 | openfilename.hInstance = Globals.hInstance; |
| 304 | openfilename.lpstrFilter = Globals.szFilter; |
| 305 | openfilename.lpstrFile = szPath; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 306 | openfilename.nMaxFile = SIZEOF(szPath); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 307 | openfilename.lpstrInitialDir = szDir; |
| 308 | openfilename.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | |
| 309 | OFN_HIDEREADONLY; |
| 310 | openfilename.lpstrDefExt = szDefaultExt; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 311 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 312 | |
Dmitry Timoshkov | 4ea5fce | 2007-08-31 16:02:01 +0900 | [diff] [blame] | 313 | if (GetOpenFileName(&openfilename)) |
| 314 | DoOpenFile(openfilename.lpstrFile); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 315 | } |
| 316 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 317 | |
Hirofumi Katayama | 32b6a1a | 2008-09-09 12:44:36 +0900 | [diff] [blame^] | 318 | BOOL DIALOG_FileSave(VOID) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 319 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 320 | if (Globals.szFileName[0] == '\0') |
Hirofumi Katayama | 32b6a1a | 2008-09-09 12:44:36 +0900 | [diff] [blame^] | 321 | return DIALOG_FileSaveAs(); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 322 | else |
| 323 | DoSaveFile(); |
Hirofumi Katayama | 32b6a1a | 2008-09-09 12:44:36 +0900 | [diff] [blame^] | 324 | return TRUE; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 325 | } |
| 326 | |
Hirofumi Katayama | 32b6a1a | 2008-09-09 12:44:36 +0900 | [diff] [blame^] | 327 | BOOL DIALOG_FileSaveAs(VOID) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 328 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 329 | OPENFILENAME saveas; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 330 | WCHAR szPath[MAX_PATH]; |
| 331 | WCHAR szDir[MAX_PATH]; |
| 332 | static const WCHAR szDefaultExt[] = { 't','x','t',0 }; |
| 333 | static const WCHAR txt_files[] = { '*','.','t','x','t',0 }; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 334 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 335 | ZeroMemory(&saveas, sizeof(saveas)); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 336 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 337 | GetCurrentDirectory(SIZEOF(szDir), szDir); |
| 338 | lstrcpy(szPath, txt_files); |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 339 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 340 | saveas.lStructSize = sizeof(OPENFILENAME); |
| 341 | saveas.hwndOwner = Globals.hMainWnd; |
| 342 | saveas.hInstance = Globals.hInstance; |
| 343 | saveas.lpstrFilter = Globals.szFilter; |
| 344 | saveas.lpstrFile = szPath; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 345 | saveas.nMaxFile = SIZEOF(szPath); |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 346 | saveas.lpstrInitialDir = szDir; |
| 347 | saveas.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | |
| 348 | OFN_HIDEREADONLY; |
| 349 | saveas.lpstrDefExt = szDefaultExt; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 350 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 351 | if (GetSaveFileName(&saveas)) { |
| 352 | SetFileName(szPath); |
| 353 | UpdateWindowCaption(); |
| 354 | DoSaveFile(); |
Hirofumi Katayama | 32b6a1a | 2008-09-09 12:44:36 +0900 | [diff] [blame^] | 355 | return TRUE; |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 356 | } |
Hirofumi Katayama | 32b6a1a | 2008-09-09 12:44:36 +0900 | [diff] [blame^] | 357 | return FALSE; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 358 | } |
| 359 | |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 360 | typedef struct { |
| 361 | LPWSTR mptr; |
| 362 | LPWSTR mend; |
| 363 | LPWSTR lptr; |
| 364 | DWORD len; |
| 365 | } TEXTINFO, *LPTEXTINFO; |
| 366 | |
| 367 | static int notepad_print_header(HDC hdc, RECT *rc, BOOL dopage, BOOL header, int page, LPWSTR text) |
| 368 | { |
| 369 | SIZE szMetric; |
| 370 | |
| 371 | if (*text) |
| 372 | { |
| 373 | /* Write the header or footer */ |
| 374 | GetTextExtentPoint32(hdc, text, lstrlen(text), &szMetric); |
| 375 | if (dopage) |
| 376 | ExtTextOut(hdc, (rc->left + rc->right - szMetric.cx) / 2, |
| 377 | header ? rc->top : rc->bottom - szMetric.cy, |
| 378 | ETO_CLIPPED, rc, text, lstrlen(text), NULL); |
| 379 | return 1; |
| 380 | } |
| 381 | return 0; |
| 382 | } |
| 383 | |
| 384 | static BOOL notepad_print_page(HDC hdc, RECT *rc, BOOL dopage, int page, LPTEXTINFO tInfo) |
| 385 | { |
| 386 | int b, y; |
| 387 | TEXTMETRIC tm; |
| 388 | SIZE szMetrics; |
| 389 | |
| 390 | if (dopage) |
| 391 | { |
| 392 | if (StartPage(hdc) <= 0) |
| 393 | { |
| 394 | static const WCHAR failedW[] = { 'S','t','a','r','t','P','a','g','e',' ','f','a','i','l','e','d',0 }; |
| 395 | static const WCHAR errorW[] = { 'P','r','i','n','t',' ','E','r','r','o','r',0 }; |
| 396 | MessageBox(Globals.hMainWnd, failedW, errorW, MB_ICONEXCLAMATION); |
| 397 | return FALSE; |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | GetTextMetrics(hdc, &tm); |
| 402 | y = rc->top + notepad_print_header(hdc, rc, dopage, TRUE, page, Globals.szFileName) * tm.tmHeight; |
| 403 | b = rc->bottom - 2 * notepad_print_header(hdc, rc, FALSE, FALSE, page, Globals.szFooter) * tm.tmHeight; |
| 404 | |
| 405 | do { |
| 406 | INT m, n; |
| 407 | |
| 408 | if (!tInfo->len) |
| 409 | { |
| 410 | /* find the end of the line */ |
| 411 | while (tInfo->mptr < tInfo->mend && *tInfo->mptr != '\n' && *tInfo->mptr != '\r') |
| 412 | { |
| 413 | if (*tInfo->mptr == '\t') |
| 414 | { |
| 415 | /* replace tabs with spaces */ |
| 416 | for (m = 0; m < SPACES_IN_TAB; m++) |
| 417 | { |
| 418 | if (tInfo->len < PRINT_LEN_MAX) |
| 419 | tInfo->lptr[tInfo->len++] = ' '; |
| 420 | else if (Globals.bWrapLongLines) |
| 421 | break; |
| 422 | } |
| 423 | } |
| 424 | else if (tInfo->len < PRINT_LEN_MAX) |
| 425 | tInfo->lptr[tInfo->len++] = *tInfo->mptr; |
| 426 | |
| 427 | if (tInfo->len >= PRINT_LEN_MAX && Globals.bWrapLongLines) |
| 428 | break; |
| 429 | |
| 430 | tInfo->mptr++; |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | /* Find out how much we should print if line wrapping is enabled */ |
| 435 | if (Globals.bWrapLongLines) |
| 436 | { |
| 437 | GetTextExtentExPoint(hdc, tInfo->lptr, tInfo->len, rc->right - rc->left, &n, NULL, &szMetrics); |
| 438 | if (n < tInfo->len && tInfo->lptr[n] != ' ') |
| 439 | { |
| 440 | m = n; |
| 441 | /* Don't wrap words unless it's a single word over the entire line */ |
| 442 | while (m && tInfo->lptr[m] != ' ') m--; |
| 443 | if (m > 0) n = m + 1; |
| 444 | } |
| 445 | } |
| 446 | else |
| 447 | n = tInfo->len; |
| 448 | |
| 449 | if (dopage) |
| 450 | ExtTextOut(hdc, rc->left, y, ETO_CLIPPED, rc, tInfo->lptr, n, NULL); |
| 451 | |
| 452 | tInfo->len -= n; |
| 453 | |
| 454 | if (tInfo->len) |
| 455 | { |
| 456 | memcpy(tInfo->lptr, tInfo->lptr + n, tInfo->len * sizeof(WCHAR)); |
| 457 | y += tm.tmHeight + tm.tmExternalLeading; |
| 458 | } |
| 459 | else |
| 460 | { |
| 461 | /* find the next line */ |
| 462 | while (tInfo->mptr < tInfo->mend && y < b && (*tInfo->mptr == '\n' || *tInfo->mptr == '\r')) |
| 463 | { |
| 464 | if (*tInfo->mptr == '\n') |
| 465 | y += tm.tmHeight + tm.tmExternalLeading; |
| 466 | tInfo->mptr++; |
| 467 | } |
| 468 | } |
| 469 | } while (tInfo->mptr < tInfo->mend && y < b); |
| 470 | |
| 471 | notepad_print_header(hdc, rc, dopage, FALSE, page, Globals.szFooter); |
| 472 | if (dopage) |
| 473 | { |
| 474 | EndPage(hdc); |
| 475 | } |
| 476 | return TRUE; |
| 477 | } |
| 478 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 479 | VOID DIALOG_FilePrint(VOID) |
| 480 | { |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 481 | DOCINFO di; |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 482 | PRINTDLG printer; |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 483 | int page, dopage, copy; |
| 484 | LOGFONT lfFont; |
| 485 | HFONT hTextFont, old_font = 0; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 486 | DWORD size; |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 487 | BOOL ret = FALSE; |
| 488 | RECT rc; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 489 | LPWSTR pTemp; |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 490 | TEXTINFO tInfo; |
Duane Clark | a60ee9c | 2006-07-16 16:20:30 -0700 | [diff] [blame] | 491 | WCHAR cTemp[PRINT_LEN_MAX]; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 492 | |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 493 | /* Get Current Settings */ |
| 494 | ZeroMemory(&printer, sizeof(printer)); |
| 495 | printer.lStructSize = sizeof(printer); |
| 496 | printer.hwndOwner = Globals.hMainWnd; |
Robert Shearman | 8be66cb | 2005-12-08 11:57:58 +0100 | [diff] [blame] | 497 | printer.hDevMode = Globals.hDevMode; |
| 498 | printer.hDevNames = Globals.hDevNames; |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 499 | printer.hInstance = Globals.hInstance; |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 500 | |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 501 | /* Set some default flags */ |
Duane Clark | a60ee9c | 2006-07-16 16:20:30 -0700 | [diff] [blame] | 502 | printer.Flags = PD_RETURNDC | PD_NOSELECTION; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 503 | printer.nFromPage = 0; |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 504 | printer.nMinPage = 1; |
| 505 | /* we really need to calculate number of pages to set nMaxPage and nToPage */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 506 | printer.nToPage = 0; |
| 507 | printer.nMaxPage = -1; |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 508 | /* Let commdlg manage copy settings */ |
| 509 | printer.nCopies = (WORD)PD_USEDEVMODECOPIES; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 510 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 511 | if (!PrintDlg(&printer)) return; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 512 | |
Robert Shearman | 8be66cb | 2005-12-08 11:57:58 +0100 | [diff] [blame] | 513 | Globals.hDevMode = printer.hDevMode; |
| 514 | Globals.hDevNames = printer.hDevNames; |
| 515 | |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 516 | SetMapMode(printer.hDC, MM_TEXT); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 517 | |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 518 | /* initialize DOCINFO */ |
| 519 | di.cbSize = sizeof(DOCINFO); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 520 | di.lpszDocName = Globals.szFileTitle; |
| 521 | di.lpszOutput = NULL; |
| 522 | di.lpszDatatype = NULL; |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 523 | di.fwType = 0; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 524 | |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 525 | /* Get the file text */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 526 | size = GetWindowTextLength(Globals.hEdit) + 1; |
| 527 | pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 528 | if (!pTemp) |
| 529 | { |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 530 | DeleteDC(printer.hDC); |
| 531 | ShowLastError(); |
| 532 | return; |
Duane Clark | 4eb4c04 | 2002-10-21 18:22:15 +0000 | [diff] [blame] | 533 | } |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 534 | size = GetWindowText(Globals.hEdit, pTemp, size); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 535 | |
Rolf Kalbermatter | 5eb6c11 | 2007-04-06 19:50:37 +0200 | [diff] [blame] | 536 | if (StartDoc(printer.hDC, &di) > 0) |
| 537 | { |
| 538 | /* Get the page margins in pixels. */ |
| 539 | rc.top = MulDiv(Globals.iMarginTop, GetDeviceCaps(printer.hDC, LOGPIXELSY), 2540) - |
| 540 | GetDeviceCaps(printer.hDC, PHYSICALOFFSETY); |
| 541 | rc.bottom = GetDeviceCaps(printer.hDC, PHYSICALHEIGHT) - |
| 542 | MulDiv(Globals.iMarginBottom, GetDeviceCaps(printer.hDC, LOGPIXELSY), 2540); |
| 543 | rc.left = MulDiv(Globals.iMarginLeft, GetDeviceCaps(printer.hDC, LOGPIXELSX), 2540) - |
| 544 | GetDeviceCaps(printer.hDC, PHYSICALOFFSETX); |
| 545 | rc.right = GetDeviceCaps(printer.hDC, PHYSICALWIDTH) - |
| 546 | MulDiv(Globals.iMarginRight, GetDeviceCaps(printer.hDC, LOGPIXELSX), 2540); |
| 547 | |
| 548 | /* Create a font for the printer resolution */ |
| 549 | lfFont = Globals.lfFont; |
| 550 | lfFont.lfHeight = MulDiv(lfFont.lfHeight, GetDeviceCaps(printer.hDC, LOGPIXELSY), get_dpi()); |
| 551 | /* Make the font a bit lighter */ |
| 552 | lfFont.lfWeight -= 100; |
| 553 | hTextFont = CreateFontIndirect(&lfFont); |
| 554 | old_font = SelectObject(printer.hDC, hTextFont); |
| 555 | |
| 556 | for (copy = 1; copy <= printer.nCopies; copy++) |
| 557 | { |
| 558 | page = 1; |
| 559 | |
| 560 | tInfo.mptr = pTemp; |
| 561 | tInfo.mend = pTemp + size; |
| 562 | tInfo.lptr = cTemp; |
| 563 | tInfo.len = 0; |
| 564 | |
| 565 | do { |
| 566 | if (printer.Flags & PD_PAGENUMS) |
| 567 | { |
| 568 | /* a specific range of pages is selected, so |
| 569 | * skip pages that are not to be printed |
| 570 | */ |
| 571 | if (page > printer.nToPage) |
| 572 | break; |
| 573 | else if (page >= printer.nFromPage) |
| 574 | dopage = 1; |
| 575 | else |
| 576 | dopage = 0; |
| 577 | } |
| 578 | else |
| 579 | dopage = 1; |
| 580 | |
| 581 | ret = notepad_print_page(printer.hDC, &rc, dopage, page, &tInfo); |
| 582 | page++; |
| 583 | } while (ret && tInfo.mptr < tInfo.mend); |
| 584 | |
| 585 | if (!ret) break; |
| 586 | } |
| 587 | EndDoc(printer.hDC); |
| 588 | SelectObject(printer.hDC, old_font); |
| 589 | DeleteObject(hTextFont); |
| 590 | } |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 591 | DeleteDC(printer.hDC); |
Michael Stefaniuc | 81a7aad | 2003-09-27 02:25:21 +0000 | [diff] [blame] | 592 | HeapFree(GetProcessHeap(), 0, pTemp); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | VOID DIALOG_FilePrinterSetup(VOID) |
| 596 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 597 | PRINTDLG printer; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 598 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 599 | ZeroMemory(&printer, sizeof(printer)); |
| 600 | printer.lStructSize = sizeof(printer); |
| 601 | printer.hwndOwner = Globals.hMainWnd; |
Robert Shearman | 8be66cb | 2005-12-08 11:57:58 +0100 | [diff] [blame] | 602 | printer.hDevMode = Globals.hDevMode; |
| 603 | printer.hDevNames = Globals.hDevNames; |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 604 | printer.hInstance = Globals.hInstance; |
| 605 | printer.Flags = PD_PRINTSETUP; |
| 606 | printer.nCopies = 1; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 607 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 608 | PrintDlg(&printer); |
Robert Shearman | 8be66cb | 2005-12-08 11:57:58 +0100 | [diff] [blame] | 609 | |
| 610 | Globals.hDevMode = printer.hDevMode; |
| 611 | Globals.hDevNames = printer.hDevNames; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | VOID DIALOG_FileExit(VOID) |
| 615 | { |
Andriy Palamarchuk | 83ad886 | 2002-07-16 01:09:24 +0000 | [diff] [blame] | 616 | PostMessage(Globals.hMainWnd, WM_CLOSE, 0, 0l); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | VOID DIALOG_EditUndo(VOID) |
| 620 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 621 | SendMessage(Globals.hEdit, EM_UNDO, 0, 0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | VOID DIALOG_EditCut(VOID) |
| 625 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 626 | SendMessage(Globals.hEdit, WM_CUT, 0, 0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | VOID DIALOG_EditCopy(VOID) |
| 630 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 631 | SendMessage(Globals.hEdit, WM_COPY, 0, 0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 632 | } |
| 633 | |
| 634 | VOID DIALOG_EditPaste(VOID) |
| 635 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 636 | SendMessage(Globals.hEdit, WM_PASTE, 0, 0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | VOID DIALOG_EditDelete(VOID) |
| 640 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 641 | SendMessage(Globals.hEdit, WM_CLEAR, 0, 0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | VOID DIALOG_EditSelectAll(VOID) |
| 645 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 646 | SendMessage(Globals.hEdit, EM_SETSEL, 0, (LPARAM)-1); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | VOID DIALOG_EditTimeDate(VOID) |
| 650 | { |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 651 | SYSTEMTIME st; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 652 | WCHAR szDate[MAX_STRING_LEN]; |
| 653 | static const WCHAR spaceW[] = { ' ',0 }; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 654 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 655 | GetLocalTime(&st); |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 656 | |
| 657 | GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, szDate, MAX_STRING_LEN); |
| 658 | SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szDate); |
| 659 | |
| 660 | SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)spaceW); |
| 661 | |
| 662 | GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szDate, MAX_STRING_LEN); |
| 663 | SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szDate); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 664 | } |
| 665 | |
| 666 | VOID DIALOG_EditWrap(VOID) |
| 667 | { |
Byeong-Sik Jeon | 53a4894 | 2006-09-16 09:43:07 +0900 | [diff] [blame] | 668 | BOOL modify = FALSE; |
Lauri Tulmin | a118603 | 2005-02-14 11:51:27 +0000 | [diff] [blame] | 669 | static const WCHAR editW[] = { 'e','d','i','t',0 }; |
| 670 | DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | |
| 671 | ES_AUTOVSCROLL | ES_MULTILINE; |
| 672 | RECT rc; |
| 673 | DWORD size; |
| 674 | LPWSTR pTemp; |
| 675 | |
| 676 | size = GetWindowTextLength(Globals.hEdit) + 1; |
| 677 | pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR)); |
| 678 | if (!pTemp) |
| 679 | { |
| 680 | ShowLastError(); |
| 681 | return; |
| 682 | } |
| 683 | GetWindowText(Globals.hEdit, pTemp, size); |
Byeong-Sik Jeon | 53a4894 | 2006-09-16 09:43:07 +0900 | [diff] [blame] | 684 | modify = SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0); |
Lauri Tulmin | a118603 | 2005-02-14 11:51:27 +0000 | [diff] [blame] | 685 | DestroyWindow(Globals.hEdit); |
| 686 | GetClientRect(Globals.hMainWnd, &rc); |
| 687 | if( Globals.bWrapLongLines ) dwStyle |= WS_HSCROLL | ES_AUTOHSCROLL; |
| 688 | Globals.hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, editW, NULL, dwStyle, |
| 689 | 0, 0, rc.right, rc.bottom, Globals.hMainWnd, |
| 690 | NULL, Globals.hInstance, NULL); |
| 691 | SendMessage(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)FALSE); |
| 692 | SetWindowTextW(Globals.hEdit, pTemp); |
Byeong-Sik Jeon | 53a4894 | 2006-09-16 09:43:07 +0900 | [diff] [blame] | 693 | SendMessage(Globals.hEdit, EM_SETMODIFY, (WPARAM)modify, 0); |
Lauri Tulmin | a118603 | 2005-02-14 11:51:27 +0000 | [diff] [blame] | 694 | SetFocus(Globals.hEdit); |
| 695 | HeapFree(GetProcessHeap(), 0, pTemp); |
| 696 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 697 | Globals.bWrapLongLines = !Globals.bWrapLongLines; |
| 698 | CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP, |
| 699 | MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED)); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 700 | } |
| 701 | |
Shachar Shemesh | fc0d07f | 2003-01-28 01:10:28 +0000 | [diff] [blame] | 702 | VOID DIALOG_SelectFont(VOID) |
| 703 | { |
| 704 | CHOOSEFONT cf; |
| 705 | LOGFONT lf=Globals.lfFont; |
| 706 | |
| 707 | ZeroMemory( &cf, sizeof(cf) ); |
| 708 | cf.lStructSize=sizeof(cf); |
| 709 | cf.hwndOwner=Globals.hMainWnd; |
| 710 | cf.lpLogFont=&lf; |
Pavel Roskin | 5f5418a | 2005-12-01 12:35:13 +0100 | [diff] [blame] | 711 | cf.Flags=CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; |
Shachar Shemesh | fc0d07f | 2003-01-28 01:10:28 +0000 | [diff] [blame] | 712 | |
| 713 | if( ChooseFont(&cf) ) |
| 714 | { |
| 715 | HFONT currfont=Globals.hFont; |
| 716 | |
| 717 | Globals.hFont=CreateFontIndirect( &lf ); |
| 718 | Globals.lfFont=lf; |
| 719 | SendMessage( Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, (LPARAM)TRUE ); |
| 720 | if( currfont!=NULL ) |
| 721 | DeleteObject( currfont ); |
| 722 | } |
| 723 | } |
| 724 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 725 | VOID DIALOG_Search(VOID) |
| 726 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 727 | ZeroMemory(&Globals.find, sizeof(Globals.find)); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 728 | Globals.find.lStructSize = sizeof(Globals.find); |
| 729 | Globals.find.hwndOwner = Globals.hMainWnd; |
| 730 | Globals.find.hInstance = Globals.hInstance; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 731 | Globals.find.lpstrFindWhat = Globals.szFindText; |
| 732 | Globals.find.wFindWhatLen = SIZEOF(Globals.szFindText); |
Mikołaj Zalewski | 84fc75c | 2006-10-22 18:58:12 +0200 | [diff] [blame] | 733 | Globals.find.Flags = FR_DOWN|FR_HIDEWHOLEWORD; |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 734 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 735 | /* We only need to create the modal FindReplace dialog which will */ |
| 736 | /* notify us of incoming events using hMainWnd Window Messages */ |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 737 | |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 738 | Globals.hFindReplaceDlg = FindText(&Globals.find); |
| 739 | assert(Globals.hFindReplaceDlg !=0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | VOID DIALOG_SearchNext(VOID) |
| 743 | { |
Mikołaj Zalewski | 84fc75c | 2006-10-22 18:58:12 +0200 | [diff] [blame] | 744 | if (Globals.lastFind.lpstrFindWhat == NULL) |
| 745 | DIALOG_Search(); |
| 746 | else /* use the last find data */ |
| 747 | NOTEPAD_DoFind(&Globals.lastFind); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | VOID DIALOG_HelpContents(VOID) |
| 751 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 752 | WinHelp(Globals.hMainWnd, helpfileW, HELP_INDEX, 0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 753 | } |
| 754 | |
| 755 | VOID DIALOG_HelpSearch(VOID) |
| 756 | { |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 757 | /* Search Help */ |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 758 | } |
| 759 | |
| 760 | VOID DIALOG_HelpHelp(VOID) |
| 761 | { |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 762 | WinHelp(Globals.hMainWnd, helpfileW, HELP_HELPONHELP, 0); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 763 | } |
| 764 | |
Rob Shearman | 90efadc | 2008-03-28 17:53:31 +0000 | [diff] [blame] | 765 | VOID DIALOG_HelpAboutNotepad(VOID) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 766 | { |
Alexandre Julliard | 247754f | 2008-03-21 18:39:31 +0100 | [diff] [blame] | 767 | static const WCHAR notepadW[] = { 'W','i','n','e',' ','N','o','t','e','p','a','d',0 }; |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 768 | WCHAR szNotepad[MAX_STRING_LEN]; |
Alexandre Julliard | 247754f | 2008-03-21 18:39:31 +0100 | [diff] [blame] | 769 | HICON icon = LoadImageW( Globals.hInstance, MAKEINTRESOURCE(IDI_NOTEPAD), |
| 770 | IMAGE_ICON, 48, 48, LR_SHARED ); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 771 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 772 | LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, SIZEOF(szNotepad)); |
Alexander Nicolaysen Sørnes | 29b69c5 | 2007-08-25 18:26:15 +0200 | [diff] [blame] | 773 | ShellAbout(Globals.hMainWnd, szNotepad, notepadW, icon); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 774 | } |
| 775 | |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 776 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 777 | /*********************************************************************** |
| 778 | * |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 779 | * DIALOG_FilePageSetup |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 780 | */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 781 | VOID DIALOG_FilePageSetup(void) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 782 | { |
Andriy Palamarchuk | c55dce0 | 2002-07-08 19:41:09 +0000 | [diff] [blame] | 783 | DialogBox(Globals.hInstance, MAKEINTRESOURCE(DIALOG_PAGESETUP), |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 784 | Globals.hMainWnd, DIALOG_PAGESETUP_DlgProc); |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 785 | } |
| 786 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 787 | |
| 788 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 789 | * |
| 790 | * DIALOG_PAGESETUP_DlgProc |
| 791 | */ |
| 792 | |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 793 | static INT_PTR WINAPI DIALOG_PAGESETUP_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 794 | { |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 795 | |
| 796 | switch (msg) |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 797 | { |
| 798 | case WM_COMMAND: |
| 799 | switch (wParam) |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 800 | { |
| 801 | case IDOK: |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 802 | /* save user input and close dialog */ |
Rolf Kalbermatter | 3cae920 | 2007-04-01 20:52:08 +0200 | [diff] [blame] | 803 | GetDlgItemText(hDlg, IDC_PAGESETUP_HEADERVALUE, Globals.szHeader, SIZEOF(Globals.szHeader)); |
| 804 | GetDlgItemText(hDlg, IDC_PAGESETUP_FOOTERVALUE, Globals.szFooter, SIZEOF(Globals.szFooter)); |
| 805 | |
| 806 | Globals.iMarginTop = GetDlgItemInt(hDlg, IDC_PAGESETUP_TOPVALUE, NULL, FALSE) * 100; |
| 807 | Globals.iMarginBottom = GetDlgItemInt(hDlg, IDC_PAGESETUP_BOTTOMVALUE, NULL, FALSE) * 100; |
| 808 | Globals.iMarginLeft = GetDlgItemInt(hDlg, IDC_PAGESETUP_LEFTVALUE, NULL, FALSE) * 100; |
| 809 | Globals.iMarginRight = GetDlgItemInt(hDlg, IDC_PAGESETUP_RIGHTVALUE, NULL, FALSE) * 100; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 810 | EndDialog(hDlg, IDOK); |
| 811 | return TRUE; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 812 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 813 | case IDCANCEL: |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 814 | /* discard user input and close dialog */ |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 815 | EndDialog(hDlg, IDCANCEL); |
| 816 | return TRUE; |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 817 | |
| 818 | case IDHELP: |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 819 | { |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 820 | /* FIXME: Bring this to work */ |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 821 | static const WCHAR sorryW[] = { 'S','o','r','r','y',',',' ','n','o',' ','h','e','l','p',' ','a','v','a','i','l','a','b','l','e',0 }; |
| 822 | static const WCHAR helpW[] = { 'H','e','l','p',0 }; |
| 823 | MessageBox(Globals.hMainWnd, sorryW, helpW, MB_ICONEXCLAMATION); |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 824 | return TRUE; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 825 | } |
Dmitry Timoshkov | 398af16 | 2003-07-21 20:05:33 +0000 | [diff] [blame] | 826 | |
| 827 | default: |
| 828 | break; |
| 829 | } |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 830 | break; |
| 831 | |
| 832 | case WM_INITDIALOG: |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 833 | /* fetch last user input prior to display dialog */ |
Rolf Kalbermatter | 3cae920 | 2007-04-01 20:52:08 +0200 | [diff] [blame] | 834 | SetDlgItemText(hDlg, IDC_PAGESETUP_HEADERVALUE, Globals.szHeader); |
| 835 | SetDlgItemText(hDlg, IDC_PAGESETUP_FOOTERVALUE, Globals.szFooter); |
| 836 | SetDlgItemInt(hDlg, IDC_PAGESETUP_TOPVALUE, Globals.iMarginTop / 100, FALSE); |
| 837 | SetDlgItemInt(hDlg, IDC_PAGESETUP_BOTTOMVALUE, Globals.iMarginBottom / 100, FALSE); |
| 838 | SetDlgItemInt(hDlg, IDC_PAGESETUP_LEFTVALUE, Globals.iMarginLeft / 100, FALSE); |
| 839 | SetDlgItemInt(hDlg, IDC_PAGESETUP_RIGHTVALUE, Globals.iMarginRight / 100, FALSE); |
Marcel Baur | a43295d | 1998-10-18 14:11:42 +0000 | [diff] [blame] | 840 | break; |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 841 | } |
Marcel Baur | 0328745 | 1999-02-14 11:28:37 +0000 | [diff] [blame] | 842 | |
Alexandre Julliard | 03468f7 | 1998-02-15 19:40:49 +0000 | [diff] [blame] | 843 | return FALSE; |
| 844 | } |