1 /* 2 * Notepad 3 * 4 * Copyright 2000 Mike McCormack <Mike_McCormack@looksmart.com.au> 5 * Copyright 1997,98 Marcel Baur <mbaur@g26.ethz.ch> 6 * Copyright 2002 Sylvain Petreolle <spetreolle@yahoo.fr> 7 * Copyright 2002 Andriy Palamarchuk 8 * Copyright 2020 Katayama Hirofumi MZ 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 * 24 */ 25 26 #include "notepad.h" 27 28 #include <shlobj.h> 29 #include <strsafe.h> 30 31 NOTEPAD_GLOBALS Globals; 32 static ATOM aFINDMSGSTRING; 33 34 VOID NOTEPAD_EnableSearchMenu() 35 { 36 EnableMenuItem(Globals.hMenu, CMD_SEARCH, 37 MF_BYCOMMAND | ((GetWindowTextLength(Globals.hEdit) == 0) ? MF_DISABLED | MF_GRAYED : MF_ENABLED)); 38 EnableMenuItem(Globals.hMenu, CMD_SEARCH_NEXT, 39 MF_BYCOMMAND | ((GetWindowTextLength(Globals.hEdit) == 0) ? MF_DISABLED | MF_GRAYED : MF_ENABLED)); 40 } 41 42 /*********************************************************************** 43 * 44 * SetFileName 45 * 46 * Sets Global File Name. 47 */ 48 VOID SetFileName(LPCTSTR szFileName) 49 { 50 StringCchCopy(Globals.szFileName, ARRAY_SIZE(Globals.szFileName), szFileName); 51 Globals.szFileTitle[0] = 0; 52 GetFileTitle(szFileName, Globals.szFileTitle, ARRAY_SIZE(Globals.szFileTitle)); 53 54 if (szFileName && szFileName[0]) 55 SHAddToRecentDocs(SHARD_PATHW, szFileName); 56 } 57 58 /*********************************************************************** 59 * 60 * NOTEPAD_MenuCommand 61 * 62 * All handling of main menu events 63 */ 64 static int NOTEPAD_MenuCommand(WPARAM wParam) 65 { 66 switch (wParam) 67 { 68 case CMD_NEW: DIALOG_FileNew(); break; 69 case CMD_OPEN: DIALOG_FileOpen(); break; 70 case CMD_SAVE: DIALOG_FileSave(); break; 71 case CMD_SAVE_AS: DIALOG_FileSaveAs(); break; 72 case CMD_PRINT: DIALOG_FilePrint(); break; 73 case CMD_PAGE_SETUP: DIALOG_FilePageSetup(); break; 74 case CMD_EXIT: DIALOG_FileExit(); break; 75 76 case CMD_UNDO: DIALOG_EditUndo(); break; 77 case CMD_CUT: DIALOG_EditCut(); break; 78 case CMD_COPY: DIALOG_EditCopy(); break; 79 case CMD_PASTE: DIALOG_EditPaste(); break; 80 case CMD_DELETE: DIALOG_EditDelete(); break; 81 case CMD_SELECT_ALL: DIALOG_EditSelectAll(); break; 82 case CMD_TIME_DATE: DIALOG_EditTimeDate(); break; 83 84 case CMD_SEARCH: DIALOG_Search(); break; 85 case CMD_SEARCH_NEXT: DIALOG_SearchNext(); break; 86 case CMD_REPLACE: DIALOG_Replace(); break; 87 case CMD_GOTO: DIALOG_GoTo(); break; 88 89 case CMD_WRAP: DIALOG_EditWrap(); break; 90 case CMD_FONT: DIALOG_SelectFont(); break; 91 92 case CMD_STATUSBAR: DIALOG_ViewStatusBar(); break; 93 94 case CMD_HELP_CONTENTS: DIALOG_HelpContents(); break; 95 case CMD_HELP_ABOUT_NOTEPAD: DIALOG_HelpAboutNotepad(); break; 96 97 default: 98 break; 99 } 100 return 0; 101 } 102 103 /*********************************************************************** 104 * 105 * NOTEPAD_FindTextAt 106 */ 107 108 static BOOL 109 NOTEPAD_FindTextAt(FINDREPLACE *pFindReplace, LPCTSTR pszText, int iTextLength, DWORD dwPosition) 110 { 111 BOOL bMatches; 112 size_t iTargetLength; 113 114 if ((!pFindReplace) || (!pszText)) 115 { 116 return FALSE; 117 } 118 119 iTargetLength = _tcslen(pFindReplace->lpstrFindWhat); 120 121 /* Make proper comparison */ 122 if (pFindReplace->Flags & FR_MATCHCASE) 123 bMatches = !_tcsncmp(&pszText[dwPosition], pFindReplace->lpstrFindWhat, iTargetLength); 124 else 125 bMatches = !_tcsnicmp(&pszText[dwPosition], pFindReplace->lpstrFindWhat, iTargetLength); 126 127 if (bMatches && pFindReplace->Flags & FR_WHOLEWORD) 128 { 129 if ((dwPosition > 0) && !_istspace(pszText[dwPosition-1])) 130 bMatches = FALSE; 131 if ((dwPosition < (DWORD) iTextLength - 1) && !_istspace(pszText[dwPosition+1])) 132 bMatches = FALSE; 133 } 134 135 return bMatches; 136 } 137 138 /*********************************************************************** 139 * 140 * NOTEPAD_FindNext 141 */ 142 143 BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert) 144 { 145 int iTextLength, iTargetLength; 146 size_t iAdjustment = 0; 147 LPTSTR pszText = NULL; 148 DWORD dwPosition, dwBegin, dwEnd; 149 BOOL bMatches = FALSE; 150 TCHAR szResource[128], szText[128]; 151 BOOL bSuccess; 152 153 iTargetLength = (int) _tcslen(pFindReplace->lpstrFindWhat); 154 155 /* Retrieve the window text */ 156 iTextLength = GetWindowTextLength(Globals.hEdit); 157 if (iTextLength > 0) 158 { 159 pszText = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, (iTextLength + 1) * sizeof(TCHAR)); 160 if (!pszText) 161 return FALSE; 162 163 GetWindowText(Globals.hEdit, pszText, iTextLength + 1); 164 } 165 166 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwBegin, (LPARAM) &dwEnd); 167 if (bReplace && ((dwEnd - dwBegin) == (DWORD) iTargetLength)) 168 { 169 if (NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwBegin)) 170 { 171 SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM) pFindReplace->lpstrReplaceWith); 172 iAdjustment = _tcslen(pFindReplace->lpstrReplaceWith) - (dwEnd - dwBegin); 173 } 174 } 175 176 if (pFindReplace->Flags & FR_DOWN) 177 { 178 /* Find Down */ 179 dwPosition = dwEnd; 180 while(dwPosition < (DWORD) iTextLength) 181 { 182 bMatches = NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwPosition); 183 if (bMatches) 184 break; 185 dwPosition++; 186 } 187 } 188 else 189 { 190 /* Find Up */ 191 dwPosition = dwBegin; 192 while(dwPosition > 0) 193 { 194 dwPosition--; 195 bMatches = NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwPosition); 196 if (bMatches) 197 break; 198 } 199 } 200 201 if (bMatches) 202 { 203 /* Found target */ 204 if (dwPosition > dwBegin) 205 dwPosition += (DWORD) iAdjustment; 206 SendMessage(Globals.hEdit, EM_SETSEL, dwPosition, dwPosition + iTargetLength); 207 SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0); 208 bSuccess = TRUE; 209 } 210 else 211 { 212 /* Can't find target */ 213 if (bShowAlert) 214 { 215 LoadString(Globals.hInstance, STRING_CANNOTFIND, szResource, ARRAY_SIZE(szResource)); 216 _sntprintf(szText, ARRAY_SIZE(szText), szResource, pFindReplace->lpstrFindWhat); 217 LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource)); 218 MessageBox(Globals.hFindReplaceDlg, szText, szResource, MB_OK); 219 } 220 bSuccess = FALSE; 221 } 222 223 if (pszText) 224 HeapFree(GetProcessHeap(), 0, pszText); 225 return bSuccess; 226 } 227 228 /*********************************************************************** 229 * 230 * NOTEPAD_ReplaceAll 231 */ 232 233 static VOID NOTEPAD_ReplaceAll(FINDREPLACE *pFindReplace) 234 { 235 BOOL bShowAlert = TRUE; 236 237 SendMessage(Globals.hEdit, EM_SETSEL, 0, 0); 238 239 while (NOTEPAD_FindNext(pFindReplace, TRUE, bShowAlert)) 240 { 241 bShowAlert = FALSE; 242 } 243 } 244 245 /*********************************************************************** 246 * 247 * NOTEPAD_FindTerm 248 */ 249 250 static VOID NOTEPAD_FindTerm(VOID) 251 { 252 Globals.hFindReplaceDlg = NULL; 253 } 254 255 /*********************************************************************** 256 * Data Initialization 257 */ 258 static VOID NOTEPAD_InitData(VOID) 259 { 260 LPTSTR p = Globals.szFilter; 261 static const TCHAR txt_files[] = _T("*.txt"); 262 static const TCHAR all_files[] = _T("*.*"); 263 264 p += LoadString(Globals.hInstance, STRING_TEXT_FILES_TXT, p, MAX_STRING_LEN) + 1; 265 _tcscpy(p, txt_files); 266 p += ARRAY_SIZE(txt_files); 267 268 p += LoadString(Globals.hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN) + 1; 269 _tcscpy(p, all_files); 270 p += ARRAY_SIZE(all_files); 271 *p = '\0'; 272 Globals.find.lpstrFindWhat = NULL; 273 274 Globals.hDevMode = NULL; 275 Globals.hDevNames = NULL; 276 } 277 278 /*********************************************************************** 279 * Enable/disable items on the menu based on control state 280 */ 281 static VOID NOTEPAD_InitMenuPopup(HMENU menu, LPARAM index) 282 { 283 int enable; 284 285 UNREFERENCED_PARAMETER(index); 286 287 CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_WRAP, 288 MF_BYCOMMAND | (Globals.bWrapLongLines ? MF_CHECKED : MF_UNCHECKED)); 289 if (!Globals.bWrapLongLines) 290 { 291 CheckMenuItem(GetMenu(Globals.hMainWnd), CMD_STATUSBAR, 292 MF_BYCOMMAND | (Globals.bShowStatusBar ? MF_CHECKED : MF_UNCHECKED)); 293 } 294 EnableMenuItem(menu, CMD_UNDO, 295 SendMessage(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED); 296 EnableMenuItem(menu, CMD_PASTE, 297 IsClipboardFormatAvailable(CF_TEXT) ? MF_ENABLED : MF_GRAYED); 298 enable = (int) SendMessage(Globals.hEdit, EM_GETSEL, 0, 0); 299 enable = (HIWORD(enable) == LOWORD(enable)) ? MF_GRAYED : MF_ENABLED; 300 EnableMenuItem(menu, CMD_CUT, enable); 301 EnableMenuItem(menu, CMD_COPY, enable); 302 EnableMenuItem(menu, CMD_DELETE, enable); 303 304 EnableMenuItem(menu, CMD_SELECT_ALL, 305 GetWindowTextLength(Globals.hEdit) ? MF_ENABLED : MF_GRAYED); 306 DrawMenuBar(Globals.hMainWnd); 307 } 308 309 LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 310 { 311 switch (msg) 312 { 313 case WM_KEYDOWN: 314 case WM_KEYUP: 315 { 316 switch (wParam) 317 { 318 case VK_UP: 319 case VK_DOWN: 320 case VK_LEFT: 321 case VK_RIGHT: 322 DIALOG_StatusBarUpdateCaretPos(); 323 break; 324 default: 325 { 326 UpdateWindowCaption(FALSE); 327 break; 328 } 329 } 330 } 331 case WM_LBUTTONUP: 332 { 333 DIALOG_StatusBarUpdateCaretPos(); 334 break; 335 } 336 } 337 return CallWindowProc( Globals.EditProc, hWnd, msg, wParam, lParam); 338 } 339 340 /*********************************************************************** 341 * 342 * NOTEPAD_WndProc 343 */ 344 static LRESULT 345 WINAPI 346 NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 347 { 348 switch (msg) 349 { 350 351 case WM_CREATE: 352 Globals.hMenu = GetMenu(hWnd); 353 354 // For now, the "Help" dialog is disabled due to the lack of HTML Help support 355 EnableMenuItem(Globals.hMenu, CMD_HELP_CONTENTS, MF_BYCOMMAND | MF_GRAYED); 356 break; 357 358 case WM_COMMAND: 359 if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_HSCROLL || HIWORD(wParam) == EN_VSCROLL) 360 DIALOG_StatusBarUpdateCaretPos(); 361 if ((HIWORD(wParam) == EN_CHANGE)) 362 NOTEPAD_EnableSearchMenu(); 363 NOTEPAD_MenuCommand(LOWORD(wParam)); 364 break; 365 366 case WM_DESTROYCLIPBOARD: 367 /*MessageBox(Globals.hMainWnd, "Empty clipboard", "Debug", MB_ICONEXCLAMATION);*/ 368 break; 369 370 case WM_CLOSE: 371 if (DoCloseFile()) { 372 if (Globals.hFont) 373 DeleteObject(Globals.hFont); 374 if (Globals.hDevMode) 375 GlobalFree(Globals.hDevMode); 376 if (Globals.hDevNames) 377 GlobalFree(Globals.hDevNames); 378 DestroyWindow(hWnd); 379 } 380 break; 381 382 case WM_QUERYENDSESSION: 383 if (DoCloseFile()) { 384 return 1; 385 } 386 break; 387 388 case WM_DESTROY: 389 SetWindowLongPtr(Globals.hEdit, GWLP_WNDPROC, (LONG_PTR)Globals.EditProc); 390 NOTEPAD_SaveSettingsToRegistry(); 391 PostQuitMessage(0); 392 break; 393 394 case WM_SIZE: 395 { 396 if ((Globals.bShowStatusBar != FALSE) && (Globals.bWrapLongLines == FALSE)) 397 { 398 RECT rcStatusBar; 399 HDWP hdwp; 400 401 if (!GetWindowRect(Globals.hStatusBar, &rcStatusBar)) 402 break; 403 404 hdwp = BeginDeferWindowPos(2); 405 if (hdwp == NULL) 406 break; 407 408 hdwp = DeferWindowPos(hdwp, 409 Globals.hEdit, 410 NULL, 411 0, 412 0, 413 LOWORD(lParam), 414 HIWORD(lParam) - (rcStatusBar.bottom - rcStatusBar.top), 415 SWP_NOZORDER | SWP_NOMOVE); 416 417 if (hdwp == NULL) 418 break; 419 420 hdwp = DeferWindowPos(hdwp, 421 Globals.hStatusBar, 422 NULL, 423 0, 424 0, 425 LOWORD(lParam), 426 LOWORD(wParam), 427 SWP_NOZORDER); 428 429 if (hdwp != NULL) 430 EndDeferWindowPos(hdwp); 431 } 432 else 433 SetWindowPos(Globals.hEdit, 434 NULL, 435 0, 436 0, 437 LOWORD(lParam), 438 HIWORD(lParam), 439 SWP_NOZORDER | SWP_NOMOVE); 440 441 break; 442 } 443 444 /* The entire client area is covered by edit control and by 445 * the status bar. So there is no need to erase main background. 446 * This resolves the horrible flicker effect during windows resizes. */ 447 case WM_ERASEBKGND: 448 return 1; 449 450 case WM_SETFOCUS: 451 SetFocus(Globals.hEdit); 452 break; 453 454 case WM_DROPFILES: 455 { 456 TCHAR szFileName[MAX_PATH]; 457 HDROP hDrop = (HDROP) wParam; 458 459 DragQueryFile(hDrop, 0, szFileName, ARRAY_SIZE(szFileName)); 460 DragFinish(hDrop); 461 DoOpenFile(szFileName); 462 break; 463 } 464 case WM_CHAR: 465 case WM_INITMENUPOPUP: 466 NOTEPAD_InitMenuPopup((HMENU)wParam, lParam); 467 break; 468 default: 469 if (msg == aFINDMSGSTRING) 470 { 471 FINDREPLACE *pFindReplace = (FINDREPLACE *) lParam; 472 Globals.find = *(FINDREPLACE *) lParam; 473 474 if (pFindReplace->Flags & FR_FINDNEXT) 475 NOTEPAD_FindNext(pFindReplace, FALSE, TRUE); 476 else if (pFindReplace->Flags & FR_REPLACE) 477 NOTEPAD_FindNext(pFindReplace, TRUE, TRUE); 478 else if (pFindReplace->Flags & FR_REPLACEALL) 479 NOTEPAD_ReplaceAll(pFindReplace); 480 else if (pFindReplace->Flags & FR_DIALOGTERM) 481 NOTEPAD_FindTerm(); 482 break; 483 } 484 485 return DefWindowProc(hWnd, msg, wParam, lParam); 486 } 487 return 0; 488 } 489 490 static int AlertFileDoesNotExist(LPCTSTR szFileName) 491 { 492 return DIALOG_StringMsgBox(Globals.hMainWnd, STRING_DOESNOTEXIST, 493 szFileName, 494 MB_ICONEXCLAMATION | MB_YESNO); 495 } 496 497 static BOOL HandleCommandLine(LPTSTR cmdline) 498 { 499 BOOL opt_print = FALSE; 500 501 while (*cmdline == _T(' ') || *cmdline == _T('-') || *cmdline == _T('/')) 502 { 503 TCHAR option; 504 505 if (*cmdline++ == _T(' ')) continue; 506 507 option = *cmdline; 508 if (option) cmdline++; 509 while (*cmdline == _T(' ')) cmdline++; 510 511 switch(option) 512 { 513 case 'p': 514 case 'P': 515 opt_print = TRUE; 516 break; 517 } 518 } 519 520 if (*cmdline) 521 { 522 /* file name is passed in the command line */ 523 LPCTSTR file_name = NULL; 524 BOOL file_exists = FALSE; 525 TCHAR buf[MAX_PATH]; 526 527 if (cmdline[0] == _T('"')) 528 { 529 cmdline++; 530 cmdline[lstrlen(cmdline) - 1] = 0; 531 } 532 533 file_name = cmdline; 534 if (FileExists(file_name)) 535 { 536 file_exists = TRUE; 537 } 538 else if (!HasFileExtension(cmdline)) 539 { 540 static const TCHAR txt[] = _T(".txt"); 541 542 /* try to find file with ".txt" extension */ 543 if (!_tcscmp(txt, cmdline + _tcslen(cmdline) - _tcslen(txt))) 544 { 545 file_exists = FALSE; 546 } 547 else 548 { 549 _tcsncpy(buf, cmdline, MAX_PATH - _tcslen(txt) - 1); 550 _tcscat(buf, txt); 551 file_name = buf; 552 file_exists = FileExists(file_name); 553 } 554 } 555 556 if (file_exists) 557 { 558 DoOpenFile(file_name); 559 InvalidateRect(Globals.hMainWnd, NULL, FALSE); 560 if (opt_print) 561 { 562 DIALOG_FilePrint(); 563 return FALSE; 564 } 565 } 566 else 567 { 568 switch (AlertFileDoesNotExist(file_name)) { 569 case IDYES: 570 DoOpenFile(file_name); 571 break; 572 573 case IDNO: 574 break; 575 } 576 } 577 } 578 579 return TRUE; 580 } 581 582 /*********************************************************************** 583 * 584 * WinMain 585 */ 586 int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int show) 587 { 588 MSG msg; 589 HACCEL hAccel; 590 WNDCLASSEX wndclass; 591 HMONITOR monitor; 592 MONITORINFO info; 593 INT x, y; 594 595 static const TCHAR className[] = _T("Notepad"); 596 static const TCHAR winName[] = _T("Notepad"); 597 598 switch (GetUserDefaultUILanguage()) 599 { 600 case MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT): 601 SetProcessDefaultLayout(LAYOUT_RTL); 602 break; 603 604 default: 605 break; 606 } 607 608 UNREFERENCED_PARAMETER(prev); 609 610 aFINDMSGSTRING = (ATOM)RegisterWindowMessage(FINDMSGSTRING); 611 612 ZeroMemory(&Globals, sizeof(Globals)); 613 Globals.hInstance = hInstance; 614 NOTEPAD_LoadSettingsFromRegistry(); 615 616 ZeroMemory(&wndclass, sizeof(wndclass)); 617 wndclass.cbSize = sizeof(wndclass); 618 wndclass.lpfnWndProc = NOTEPAD_WndProc; 619 wndclass.hInstance = Globals.hInstance; 620 wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NPICON)); 621 wndclass.hCursor = LoadCursor(0, IDC_ARROW); 622 wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 623 wndclass.lpszMenuName = MAKEINTRESOURCE(MAIN_MENU); 624 wndclass.lpszClassName = className; 625 wndclass.hIconSm = (HICON)LoadImage(hInstance, 626 MAKEINTRESOURCE(IDI_NPICON), 627 IMAGE_ICON, 628 16, 629 16, 630 0); 631 632 if (!RegisterClassEx(&wndclass)) return FALSE; 633 634 /* Setup windows */ 635 636 monitor = MonitorFromRect(&Globals.main_rect, MONITOR_DEFAULTTOPRIMARY); 637 info.cbSize = sizeof(info); 638 GetMonitorInfoW(monitor, &info); 639 640 x = Globals.main_rect.left; 641 y = Globals.main_rect.top; 642 if (Globals.main_rect.left >= info.rcWork.right || 643 Globals.main_rect.top >= info.rcWork.bottom || 644 Globals.main_rect.right < info.rcWork.left || 645 Globals.main_rect.bottom < info.rcWork.top) 646 x = y = CW_USEDEFAULT; 647 648 Globals.hMainWnd = CreateWindow(className, 649 winName, 650 WS_OVERLAPPEDWINDOW, 651 x, 652 y, 653 Globals.main_rect.right - Globals.main_rect.left, 654 Globals.main_rect.bottom - Globals.main_rect.top, 655 NULL, 656 NULL, 657 Globals.hInstance, 658 NULL); 659 if (!Globals.hMainWnd) 660 { 661 ShowLastError(); 662 ExitProcess(1); 663 } 664 665 DoCreateEditWindow(); 666 667 NOTEPAD_InitData(); 668 DIALOG_FileNew(); 669 670 ShowWindow(Globals.hMainWnd, show); 671 UpdateWindow(Globals.hMainWnd); 672 DragAcceptFiles(Globals.hMainWnd, TRUE); 673 674 DIALOG_ViewStatusBar(); 675 676 if (!HandleCommandLine(cmdline)) 677 { 678 return 0; 679 } 680 681 hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL)); 682 683 while (GetMessage(&msg, 0, 0, 0)) 684 { 685 if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) && 686 !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg)) 687 { 688 TranslateMessage(&msg); 689 DispatchMessage(&msg); 690 } 691 } 692 return (int) msg.wParam; 693 } 694