ReactOS  0.4.12-dev-102-g4b7f1e0
main.c
Go to the documentation of this file.
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  *
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
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #include "notepad.h"
26 
27 #include <strsafe.h>
28 
31 
33 {
37  MF_BYCOMMAND | ((GetWindowTextLength(Globals.hEdit) == 0) ? MF_DISABLED | MF_GRAYED : MF_ENABLED));
38 }
39 
40 /***********************************************************************
41  *
42  * SetFileName
43  *
44  * Sets Global File Name.
45  */
47 {
48  StringCchCopy(Globals.szFileName, ARRAY_SIZE(Globals.szFileName), szFileName);
49  Globals.szFileTitle[0] = 0;
50  GetFileTitle(szFileName, Globals.szFileTitle, ARRAY_SIZE(Globals.szFileTitle));
51 }
52 
53 /***********************************************************************
54  *
55  * NOTEPAD_MenuCommand
56  *
57  * All handling of main menu events
58  */
60 {
61  switch (wParam)
62  {
63  case CMD_NEW: DIALOG_FileNew(); break;
64  case CMD_OPEN: DIALOG_FileOpen(); break;
65  case CMD_SAVE: DIALOG_FileSave(); break;
66  case CMD_SAVE_AS: DIALOG_FileSaveAs(); break;
67  case CMD_PRINT: DIALOG_FilePrint(); break;
68  case CMD_PAGE_SETUP: DIALOG_FilePageSetup(); break;
69  case CMD_EXIT: DIALOG_FileExit(); break;
70 
71  case CMD_UNDO: DIALOG_EditUndo(); break;
72  case CMD_CUT: DIALOG_EditCut(); break;
73  case CMD_COPY: DIALOG_EditCopy(); break;
74  case CMD_PASTE: DIALOG_EditPaste(); break;
75  case CMD_DELETE: DIALOG_EditDelete(); break;
76  case CMD_SELECT_ALL: DIALOG_EditSelectAll(); break;
77  case CMD_TIME_DATE: DIALOG_EditTimeDate(); break;
78 
79  case CMD_SEARCH: DIALOG_Search(); break;
80  case CMD_SEARCH_NEXT: DIALOG_SearchNext(); break;
81  case CMD_REPLACE: DIALOG_Replace(); break;
82  case CMD_GOTO: DIALOG_GoTo(); break;
83 
84  case CMD_WRAP: DIALOG_EditWrap(); break;
85  case CMD_FONT: DIALOG_SelectFont(); break;
86 
87  case CMD_STATUSBAR: DIALOG_ViewStatusBar(); break;
88 
91 
92  default:
93  break;
94  }
95  return 0;
96 }
97 
98 /***********************************************************************
99  *
100  * NOTEPAD_FindTextAt
101  */
102 
103 static BOOL
104 NOTEPAD_FindTextAt(FINDREPLACE *pFindReplace, LPCTSTR pszText, int iTextLength, DWORD dwPosition)
105 {
106  BOOL bMatches;
107  size_t iTargetLength;
108 
109  if ((!pFindReplace) || (!pszText))
110  {
111  return FALSE;
112  }
113 
114  iTargetLength = _tcslen(pFindReplace->lpstrFindWhat);
115 
116  /* Make proper comparison */
117  if (pFindReplace->Flags & FR_MATCHCASE)
118  bMatches = !_tcsncmp(&pszText[dwPosition], pFindReplace->lpstrFindWhat, iTargetLength);
119  else
120  bMatches = !_tcsnicmp(&pszText[dwPosition], pFindReplace->lpstrFindWhat, iTargetLength);
121 
122  if (bMatches && pFindReplace->Flags & FR_WHOLEWORD)
123  {
124  if ((dwPosition > 0) && !_istspace(pszText[dwPosition-1]))
125  bMatches = FALSE;
126  if ((dwPosition < (DWORD) iTextLength - 1) && !_istspace(pszText[dwPosition+1]))
127  bMatches = FALSE;
128  }
129 
130  return bMatches;
131 }
132 
133 /***********************************************************************
134  *
135  * NOTEPAD_FindNext
136  */
137 
138 BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
139 {
140  int iTextLength, iTargetLength;
141  size_t iAdjustment = 0;
142  LPTSTR pszText = NULL;
143  DWORD dwPosition, dwBegin, dwEnd;
144  BOOL bMatches = FALSE;
145  TCHAR szResource[128], szText[128];
146  BOOL bSuccess;
147 
148  iTargetLength = (int) _tcslen(pFindReplace->lpstrFindWhat);
149 
150  /* Retrieve the window text */
151  iTextLength = GetWindowTextLength(Globals.hEdit);
152  if (iTextLength > 0)
153  {
154  pszText = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, (iTextLength + 1) * sizeof(TCHAR));
155  if (!pszText)
156  return FALSE;
157 
158  GetWindowText(Globals.hEdit, pszText, iTextLength + 1);
159  }
160 
161  SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwBegin, (LPARAM) &dwEnd);
162  if (bReplace && ((dwEnd - dwBegin) == (DWORD) iTargetLength))
163  {
164  if (NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwBegin))
165  {
166  SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM) pFindReplace->lpstrReplaceWith);
167  iAdjustment = _tcslen(pFindReplace->lpstrReplaceWith) - (dwEnd - dwBegin);
168  }
169  }
170 
171  if (pFindReplace->Flags & FR_DOWN)
172  {
173  /* Find Down */
174  dwPosition = dwEnd;
175  while(dwPosition < (DWORD) iTextLength)
176  {
177  bMatches = NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwPosition);
178  if (bMatches)
179  break;
180  dwPosition++;
181  }
182  }
183  else
184  {
185  /* Find Up */
186  dwPosition = dwBegin;
187  while(dwPosition > 0)
188  {
189  dwPosition--;
190  bMatches = NOTEPAD_FindTextAt(pFindReplace, pszText, iTextLength, dwPosition);
191  if (bMatches)
192  break;
193  }
194  }
195 
196  if (bMatches)
197  {
198  /* Found target */
199  if (dwPosition > dwBegin)
200  dwPosition += (DWORD) iAdjustment;
201  SendMessage(Globals.hEdit, EM_SETSEL, dwPosition, dwPosition + iTargetLength);
202  SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
203  bSuccess = TRUE;
204  }
205  else
206  {
207  /* Can't find target */
208  if (bShowAlert)
209  {
210  LoadString(Globals.hInstance, STRING_CANNOTFIND, szResource, ARRAY_SIZE(szResource));
211  _sntprintf(szText, ARRAY_SIZE(szText), szResource, pFindReplace->lpstrFindWhat);
212  LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource));
213  MessageBox(Globals.hFindReplaceDlg, szText, szResource, MB_OK);
214  }
215  bSuccess = FALSE;
216  }
217 
218  if (pszText)
219  HeapFree(GetProcessHeap(), 0, pszText);
220  return bSuccess;
221 }
222 
223 /***********************************************************************
224  *
225  * NOTEPAD_ReplaceAll
226  */
227 
228 static VOID NOTEPAD_ReplaceAll(FINDREPLACE *pFindReplace)
229 {
230  BOOL bShowAlert = TRUE;
231 
232  SendMessage(Globals.hEdit, EM_SETSEL, 0, 0);
233 
234  while (NOTEPAD_FindNext(pFindReplace, TRUE, bShowAlert))
235  {
236  bShowAlert = FALSE;
237  }
238 }
239 
240 /***********************************************************************
241  *
242  * NOTEPAD_FindTerm
243  */
244 
246 {
247  Globals.hFindReplaceDlg = NULL;
248 }
249 
250 /***********************************************************************
251  * Data Initialization
252  */
254 {
255  LPTSTR p = Globals.szFilter;
256  static const TCHAR txt_files[] = _T("*.txt");
257  static const TCHAR all_files[] = _T("*.*");
258 
260  _tcscpy(p, txt_files);
261  p += ARRAY_SIZE(txt_files);
262 
263  p += LoadString(Globals.hInstance, STRING_ALL_FILES, p, MAX_STRING_LEN) + 1;
264  _tcscpy(p, all_files);
265  p += ARRAY_SIZE(all_files);
266  *p = '\0';
267  Globals.find.lpstrFindWhat = NULL;
268 
269  Globals.hDevMode = NULL;
270  Globals.hDevNames = NULL;
271 }
272 
273 /***********************************************************************
274  * Enable/disable items on the menu based on control state
275  */
277 {
278  int enable;
279 
280  UNREFERENCED_PARAMETER(index);
281 
284  if (!Globals.bWrapLongLines)
285  {
287  MF_BYCOMMAND | (Globals.bShowStatusBar ? MF_CHECKED : MF_UNCHECKED));
288  }
289  EnableMenuItem(menu, CMD_UNDO,
290  SendMessage(Globals.hEdit, EM_CANUNDO, 0, 0) ? MF_ENABLED : MF_GRAYED);
293  enable = (int) SendMessage(Globals.hEdit, EM_GETSEL, 0, 0);
294  enable = (HIWORD(enable) == LOWORD(enable)) ? MF_GRAYED : MF_ENABLED;
295  EnableMenuItem(menu, CMD_CUT, enable);
296  EnableMenuItem(menu, CMD_COPY, enable);
297  EnableMenuItem(menu, CMD_DELETE, enable);
298 
300  GetWindowTextLength(Globals.hEdit) ? MF_ENABLED : MF_GRAYED);
301  DrawMenuBar(Globals.hMainWnd);
302 }
303 
305 {
306  switch (msg)
307  {
308  case WM_KEYDOWN:
309  case WM_KEYUP:
310  {
311  switch (wParam)
312  {
313  case VK_UP:
314  case VK_DOWN:
315  case VK_LEFT:
316  case VK_RIGHT:
318  break;
319  default:
320  {
322  break;
323  }
324  }
325  }
326  case WM_LBUTTONUP:
327  {
329  break;
330  }
331  }
332  return CallWindowProc( Globals.EditProc, hWnd, msg, wParam, lParam);
333 }
334 
335 /***********************************************************************
336  *
337  * NOTEPAD_WndProc
338  */
339 static LRESULT
340 WINAPI
342 {
343  switch (msg)
344  {
345 
346  case WM_CREATE:
347  Globals.hMenu = GetMenu(hWnd);
348 
349  // For now, the "Help" dialog is disabled due to the lack of HTML Help support
351  break;
352 
353  case WM_COMMAND:
354  if (HIWORD(wParam) == EN_CHANGE || HIWORD(wParam) == EN_HSCROLL || HIWORD(wParam) == EN_VSCROLL)
356  if ((HIWORD(wParam) == EN_CHANGE))
358  NOTEPAD_MenuCommand(LOWORD(wParam));
359  break;
360 
361  case WM_DESTROYCLIPBOARD:
362  /*MessageBox(Globals.hMainWnd, "Empty clipboard", "Debug", MB_ICONEXCLAMATION);*/
363  break;
364 
365  case WM_CLOSE:
366  if (DoCloseFile()) {
367  if (Globals.hFont)
368  DeleteObject(Globals.hFont);
369  if (Globals.hDevMode)
370  GlobalFree(Globals.hDevMode);
371  if (Globals.hDevNames)
372  GlobalFree(Globals.hDevNames);
373  DestroyWindow(hWnd);
374  }
375  break;
376 
377  case WM_QUERYENDSESSION:
378  if (DoCloseFile()) {
379  return 1;
380  }
381  break;
382 
383  case WM_DESTROY:
386  PostQuitMessage(0);
387  break;
388 
389  case WM_SIZE:
390  {
391  if ((Globals.bShowStatusBar != FALSE) && (Globals.bWrapLongLines == FALSE))
392  {
393  RECT rcStatusBar;
394  HDWP hdwp;
395 
396  if (!GetWindowRect(Globals.hStatusBar, &rcStatusBar))
397  break;
398 
399  hdwp = BeginDeferWindowPos(2);
400  if (hdwp == NULL)
401  break;
402 
403  hdwp = DeferWindowPos(hdwp,
404  Globals.hEdit,
405  NULL,
406  0,
407  0,
408  LOWORD(lParam),
409  HIWORD(lParam) - (rcStatusBar.bottom - rcStatusBar.top),
411 
412  if (hdwp == NULL)
413  break;
414 
415  hdwp = DeferWindowPos(hdwp,
416  Globals.hStatusBar,
417  NULL,
418  0,
419  0,
420  LOWORD(lParam),
421  LOWORD(wParam),
422  SWP_NOZORDER);
423 
424  if (hdwp != NULL)
425  EndDeferWindowPos(hdwp);
426  }
427  else
428  SetWindowPos(Globals.hEdit,
429  NULL,
430  0,
431  0,
432  LOWORD(lParam),
433  HIWORD(lParam),
435 
436  break;
437  }
438 
439  /* The entire client area is covered by edit control and by
440  * the status bar. So there is no need to erase main background.
441  * This resolves the horrible flicker effect during windows resizes. */
442  case WM_ERASEBKGND:
443  return 1;
444 
445  case WM_SETFOCUS:
446  SetFocus(Globals.hEdit);
447  break;
448 
449  case WM_DROPFILES:
450  {
451  TCHAR szFileName[MAX_PATH];
452  HDROP hDrop = (HDROP) wParam;
453 
454  DragQueryFile(hDrop, 0, szFileName, ARRAY_SIZE(szFileName));
455  DragFinish(hDrop);
456  DoOpenFile(szFileName);
457  break;
458  }
459  case WM_CHAR:
460  case WM_INITMENUPOPUP:
461  NOTEPAD_InitMenuPopup((HMENU)wParam, lParam);
462  break;
463  default:
464  if (msg == aFINDMSGSTRING)
465  {
466  FINDREPLACE *pFindReplace = (FINDREPLACE *) lParam;
467  Globals.find = *(FINDREPLACE *) lParam;
468 
469  if (pFindReplace->Flags & FR_FINDNEXT)
470  NOTEPAD_FindNext(pFindReplace, FALSE, TRUE);
471  else if (pFindReplace->Flags & FR_REPLACE)
472  NOTEPAD_FindNext(pFindReplace, TRUE, TRUE);
473  else if (pFindReplace->Flags & FR_REPLACEALL)
474  NOTEPAD_ReplaceAll(pFindReplace);
475  else if (pFindReplace->Flags & FR_DIALOGTERM)
477  break;
478  }
479 
480  return DefWindowProc(hWnd, msg, wParam, lParam);
481  }
482  return 0;
483 }
484 
485 static int AlertFileDoesNotExist(LPCTSTR szFileName)
486 {
488  szFileName,
490 }
491 
493 {
494  BOOL opt_print = FALSE;
495 
496  while (*cmdline == _T(' ') || *cmdline == _T('-') || *cmdline == _T('/'))
497  {
498  TCHAR option;
499 
500  if (*cmdline++ == _T(' ')) continue;
501 
502  option = *cmdline;
503  if (option) cmdline++;
504  while (*cmdline == _T(' ')) cmdline++;
505 
506  switch(option)
507  {
508  case 'p':
509  case 'P':
510  opt_print = TRUE;
511  break;
512  }
513  }
514 
515  if (*cmdline)
516  {
517  /* file name is passed in the command line */
520  TCHAR buf[MAX_PATH];
521 
522  if (cmdline[0] == _T('"'))
523  {
524  cmdline++;
525  cmdline[lstrlen(cmdline) - 1] = 0;
526  }
527 
528  file_name = cmdline;
529  if (FileExists(file_name))
530  {
531  file_exists = TRUE;
532  }
533  else if (!HasFileExtension(cmdline))
534  {
535  static const TCHAR txt[] = _T(".txt");
536 
537  /* try to find file with ".txt" extension */
538  if (!_tcscmp(txt, cmdline + _tcslen(cmdline) - _tcslen(txt)))
539  {
540  file_exists = FALSE;
541  }
542  else
543  {
544  _tcsncpy(buf, cmdline, MAX_PATH - _tcslen(txt) - 1);
545  _tcscat(buf, txt);
546  file_name = buf;
547  file_exists = FileExists(file_name);
548  }
549  }
550 
551  if (file_exists)
552  {
553  DoOpenFile(file_name);
554  InvalidateRect(Globals.hMainWnd, NULL, FALSE);
555  if (opt_print)
556  {
558  return FALSE;
559  }
560  }
561  else
562  {
563  switch (AlertFileDoesNotExist(file_name)) {
564  case IDYES:
565  DoOpenFile(file_name);
566  break;
567 
568  case IDNO:
569  break;
570  }
571  }
572  }
573 
574  return TRUE;
575 }
576 
577 /***********************************************************************
578  *
579  * WinMain
580  */
582 {
583  MSG msg;
584  HACCEL hAccel;
585  WNDCLASSEX wndclass;
586  HMONITOR monitor;
588  INT x, y;
589 
590  static const TCHAR className[] = _T("Notepad");
591  static const TCHAR winName[] = _T("Notepad");
592 
593  switch (GetUserDefaultUILanguage())
594  {
597  break;
598 
599  default:
600  break;
601  }
602 
604 
606 
607  ZeroMemory(&Globals, sizeof(Globals));
608  Globals.hInstance = hInstance;
610 
611  ZeroMemory(&wndclass, sizeof(wndclass));
612  wndclass.cbSize = sizeof(wndclass);
613  wndclass.lpfnWndProc = NOTEPAD_WndProc;
614  wndclass.hInstance = Globals.hInstance;
615  wndclass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_NPICON));
616  wndclass.hCursor = LoadCursor(0, IDC_ARROW);
617  wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
619  wndclass.lpszClassName = className;
620  wndclass.hIconSm = (HICON)LoadImage(hInstance,
622  IMAGE_ICON,
623  16,
624  16,
625  0);
626 
627  if (!RegisterClassEx(&wndclass)) return FALSE;
628 
629  /* Setup windows */
630 
631  monitor = MonitorFromRect(&Globals.main_rect, MONITOR_DEFAULTTOPRIMARY);
632  info.cbSize = sizeof(info);
633  GetMonitorInfoW(monitor, &info);
634 
635  x = Globals.main_rect.left;
636  y = Globals.main_rect.top;
637  if (Globals.main_rect.left >= info.rcWork.right ||
638  Globals.main_rect.top >= info.rcWork.bottom ||
639  Globals.main_rect.right < info.rcWork.left ||
640  Globals.main_rect.bottom < info.rcWork.top)
641  x = y = CW_USEDEFAULT;
642 
643  Globals.hMainWnd = CreateWindow(className,
644  winName,
646  x,
647  y,
648  Globals.main_rect.right - Globals.main_rect.left,
649  Globals.main_rect.bottom - Globals.main_rect.top,
650  NULL,
651  NULL,
652  Globals.hInstance,
653  NULL);
654  if (!Globals.hMainWnd)
655  {
656  ShowLastError();
657  ExitProcess(1);
658  }
659 
661 
663  DIALOG_FileNew();
664 
665  ShowWindow(Globals.hMainWnd, show);
666  UpdateWindow(Globals.hMainWnd);
667  DragAcceptFiles(Globals.hMainWnd, TRUE);
668 
670 
671  if (!HandleCommandLine(cmdline))
672  {
673  return 0;
674  }
675 
676  hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(ID_ACCEL));
677 
678  while (GetMessage(&msg, 0, 0, 0))
679  {
680  if (!IsDialogMessage(Globals.hFindReplaceDlg, &msg) &&
681  !TranslateAccelerator(Globals.hMainWnd, hAccel, &msg))
682  {
683  TranslateMessage(&msg);
684  DispatchMessage(&msg);
685  }
686  }
687  return (int) msg.wParam;
688 }
#define FR_FINDNEXT
Definition: commdlg.h:131
HWND hFindReplaceDlg
Definition: main.h:61
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int show)
Definition: main.c:581
#define CallWindowProc
Definition: winuser.h:5601
VOID DIALOG_Search(VOID)
Definition: dialog.c:1069
#define TranslateAccelerator
Definition: winuser.h:5726
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5631
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:561
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define CMD_HELP_CONTENTS
Definition: notepad_res.h:63
static HICON
Definition: imagelist.c:84
HDWP WINAPI BeginDeferWindowPos(_In_ int)
#define MF_DISABLED
Definition: winuser.h:130
LPCSTR lpszMenuName
Definition: winuser.h:3163
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
NOTEPAD_GLOBALS Globals
Definition: main.c:29
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define RegisterClassEx
Definition: winuser.h:5703
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define LAYOUT_RTL
Definition: wingdi.h:1352
#define WM_CHAR
Definition: winuser.h:1693
HCURSOR hCursor
Definition: winuser.h:3161
WNDPROC lpfnWndProc
Definition: winuser.h:3156
#define CreateWindow
Definition: winuser.h:5620
#define IDYES
Definition: winuser.h:829
#define CMD_WRAP
Definition: notepad_res.h:57
VOID DIALOG_FileExit(VOID)
Definition: dialog.c:772
static VOID NOTEPAD_InitData(VOID)
Definition: main.c:253
LPCSTR lpszClassName
Definition: winuser.h:3164
WORD ATOM
Definition: dimm.idl:113
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define WM_INITMENUPOPUP
Definition: winuser.h:1722
#define DWORD
Definition: msvc.h:34
VOID DIALOG_EditSelectAll(VOID)
Definition: dialog.c:802
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
_TCHAR * _tcsncpy(_TCHAR *dst, const _TCHAR *src, size_t n)
Definition: tcsncpy.h:9
LPCWSTR pszText
Definition: msvc.h:103
#define SUBLANG_DEFAULT
Definition: nls.h:168
#define WM_QUERYENDSESSION
Definition: winuser.h:1604
#define CALLBACK
Definition: compat.h:27
#define MAIN_MENU
Definition: resources.h:12
BOOL WINAPI UpdateWindow(_In_ HWND)
void NOTEPAD_LoadSettingsFromRegistry(void)
Definition: settings.c:114
HWND hWnd
Definition: settings.c:17
void WINAPI DragAcceptFiles(HWND hWnd, BOOL b)
Definition: shellole.c:527
LONG top
Definition: windef.h:297
LPSTR lpstrFindWhat
Definition: commdlg.h:307
#define VK_LEFT
Definition: winuser.h:2178
HGLOBAL hDevNames
Definition: main.h:67
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1635
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define CMD_EXIT
Definition: resources.h:17
#define CMD_SEARCH
Definition: notepad_res.h:52
HWND WINAPI SetFocus(_In_opt_ HWND)
#define VK_DOWN
Definition: winuser.h:2181
WNDPROC EditProc
Definition: main.h:85
TCHAR * cmdline
Definition: stretchblt.cpp:32
HGLOBAL hDevMode
Definition: main.h:66
HICON hIconSm
Definition: winuser.h:3165
LONG left
Definition: windef.h:296
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
VOID DIALOG_EditCopy(VOID)
Definition: dialog.c:787
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:138
BOOL HasFileExtension(LPCTSTR szFilename)
Definition: dialog.c:162
#define IsDialogMessage
Definition: winuser.h:5675
#define CMD_GOTO
Definition: notepad_res.h:55
LONG right
Definition: windef.h:298
#define CMD_DELETE
Definition: resources.h:18
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CMD_SAVE_AS
Definition: resources.h:16
#define COLOR_WINDOW
Definition: winuser.h:908
int32_t INT
Definition: typedefs.h:56
#define LANG_HEBREW
Definition: nls.h:67
static BOOLEAN bSuccess
Definition: drive.cpp:417
#define SetWindowLongPtr
Definition: treelist.c:70
WPARAM wParam
Definition: combotst.c:138
#define CMD_PRINT
Definition: notepad_res.h:40
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define GetWindowText
Definition: winuser.h:5664
UINT_PTR WPARAM
Definition: windef.h:207
#define STRING_TEXT_FILES_TXT
Definition: notepad_res.h:80
struct _test_info info[]
Definition: SetCursorPos.c:19
HINSTANCE hInstance
Definition: main.h:59
#define EM_GETSEL
Definition: winuser.h:1958
#define FR_REPLACEALL
Definition: commdlg.h:143
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
INT INT y
Definition: msvc.h:62
#define CMD_STATUSBAR
Definition: notepad_res.h:60
#define STRING_DOESNOTEXIST
Definition: notepad_res.h:83
#define LoadAccelerators
Definition: winuser.h:5676
TCHAR szFileName[MAX_PATH]
Definition: main.h:73
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU hMenu
Definition: main.h:65
#define VK_UP
Definition: winuser.h:2179
#define STRING_NOTEPAD
Definition: notepad_res.h:74
#define MB_YESNO
Definition: winuser.h:811
HINSTANCE hInstance
Definition: winuser.h:3159
static const WCHAR szText[]
Definition: dialog.c:139
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:151
HACCEL hAccel
Definition: main.c:47
static VOID DoOpenFile(PINFO pInfo)
Definition: connectdialog.c:34
static BOOL NOTEPAD_FindTextAt(FINDREPLACE *pFindReplace, LPCTSTR pszText, int iTextLength, DWORD dwPosition)
Definition: main.c:104
#define _tcsnicmp
Definition: xmlstorage.h:207
DWORD Flags
Definition: commdlg.h:306
LONG_PTR LPARAM
Definition: windef.h:208
static VOID NOTEPAD_ReplaceAll(FINDREPLACE *pFindReplace)
Definition: main.c:228
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
BOOL DoCloseFile(VOID)
Definition: dialog.c:313
#define WM_DROPFILES
Definition: winuser.h:1801
VOID DIALOG_EditDelete(VOID)
Definition: dialog.c:797
BOOL bShowStatusBar
Definition: main.h:70
#define CW_USEDEFAULT
Definition: winuser.h:225
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
VOID DIALOG_FilePageSetup(void)
Definition: dialog.c:1209
#define CMD_OPEN
Definition: resources.h:15
UINT msg
Definition: msvc.h:92
smooth NULL
Definition: ftsmooth.c:416
#define WM_KEYDOWN
Definition: winuser.h:1691
UINT cbSize
Definition: winuser.h:3154
#define GetFileTitle
Definition: commdlg.h:664
#define CMD_REPLACE
Definition: notepad_res.h:54
static int NOTEPAD_MenuCommand(WPARAM wParam)
Definition: main.c:59
GLuint index
Definition: glext.h:6031
VOID DIALOG_SelectFont(VOID)
Definition: dialog.c:1019
HFONT hFont
Definition: main.h:64
VOID DIALOG_GoTo(VOID)
Definition: dialog.c:1123
#define STRING_ALL_FILES
Definition: notepad_res.h:79
HBRUSH hbrBackground
Definition: winuser.h:3162
VOID DIALOG_SearchNext(VOID)
Definition: dialog.c:1074
#define DefWindowProc
Definition: ros2win.h:31
#define CF_TEXT
Definition: constants.h:396
#define WM_DESTROY
Definition: winuser.h:1591
GLuint GLenum option
Definition: glext.h:11211
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:901
static int AlertFileDoesNotExist(LPCTSTR szFileName)
Definition: main.c:485
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1686
RECT main_rect
Definition: main.h:86
#define MF_CHECKED
Definition: winuser.h:132
char TCHAR
Definition: xmlstorage.h:189
#define FINDMSGSTRING
Definition: commdlg.h:653
HWND hStatusBar
Definition: main.h:63
#define FR_MATCHCASE
Definition: commdlg.h:136
#define _T(x)
Definition: vfdio.h:22
#define CMD_SAVE
Definition: notepad_res.h:38
VOID ShowLastError(VOID)
Definition: dialog.c:38
unsigned int BOOL
Definition: ntddk_ex.h:94
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CMD_COPY
Definition: notepad_res.h:46
#define WM_SIZE
Definition: winuser.h:1593
BOOL WINAPI GetMonitorInfoW(_In_ HMONITOR, _Inout_ LPMONITORINFO)
VOID DIALOG_EditPaste(VOID)
Definition: dialog.c:792
VOID DIALOG_FileOpen(VOID)
Definition: dialog.c:409
#define MF_ENABLED
Definition: winuser.h:128
#define WM_CLOSE
Definition: winuser.h:1603
#define CMD_CUT
Definition: notepad_res.h:45
#define MAX_PATH
Definition: compat.h:26
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:1165
#define EM_SETSEL
Definition: winuser.h:1979
#define WM_KEYUP
Definition: winuser.h:1692
unsigned int UINT
Definition: ndis.h:50
VOID DIALOG_FilePrint(VOID)
Definition: dialog.c:557
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CMD_PAGE_SETUP
Definition: notepad_res.h:41
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
HINSTANCE hInstance
Definition: main.c:36
#define FR_REPLACE
Definition: commdlg.h:142
#define CMD_SELECT_ALL
Definition: notepad_res.h:49
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:98
HICON hIcon
Definition: winuser.h:3160
#define StringCchCopy
Definition: strsafe.h:139
static const TCHAR txt_files[]
Definition: dialog.c:34
static LRESULT WINAPI NOTEPAD_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:341
#define _sntprintf
Definition: xmlstorage.h:201
#define CMD_UNDO
Definition: notepad_res.h:44
TCHAR szFilter[2 *MAX_STRING_LEN+100]
Definition: main.h:75
#define MessageBox
Definition: winuser.h:5688
#define WM_COMMAND
Definition: winuser.h:1716
#define MF_UNCHECKED
Definition: winuser.h:204
#define EN_HSCROLL
Definition: winuser.h:1985
#define WINAPI
Definition: msvc.h:20
#define LoadCursor
Definition: winuser.h:5678
#define GWLP_WNDPROC
Definition: treelist.c:66
#define CMD_PASTE
Definition: notepad_res.h:47
static BOOL file_exists(const WCHAR *file_name)
Definition: axinstall.c:70
#define CMD_SEARCH_NEXT
Definition: notepad_res.h:53
#define VK_RIGHT
Definition: winuser.h:2180
LPSTR lpstrReplaceWith
Definition: commdlg.h:308
#define RegisterWindowMessage
Definition: winuser.h:5706
#define EN_VSCROLL
Definition: winuser.h:1990
BOOL bWrapLongLines
Definition: main.h:69
#define FR_WHOLEWORD
Definition: commdlg.h:145
int all_files
Definition: mkisofs.c:132
#define lstrlen
Definition: winbase.h:3690
GLboolean enable
Definition: glext.h:11120
VOID DIALOG_EditUndo(VOID)
Definition: dialog.c:777
INT x
Definition: msvc.h:62
#define ARRAY_SIZE(a)
Definition: main.h:24
DWORD cbSize
Definition: winuser.h:3726
static BOOL HandleCommandLine(LPTSTR cmdline)
Definition: main.c:492
#define IDI_NPICON
Definition: notepad_res.h:32
#define WM_LBUTTONUP
Definition: winuser.h:1753
#define MAX_STRING_LEN
Definition: main.c:65
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define MB_OK
Definition: winuser.h:784
#define GetMessage
Definition: winuser.h:5656
VOID DIALOG_Replace(VOID)
Definition: dialog.c:1082
VOID DIALOG_EditCut(VOID)
Definition: dialog.c:782
#define FR_DOWN
Definition: commdlg.h:127
static LPCWSTR file_name
Definition: protocol.c:146
#define DragQueryFile
Definition: shellapi.h:672
#define STRING_CANNOTFIND
Definition: notepad_res.h:88
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:32
BOOL DIALOG_FileSaveAs(VOID)
Definition: dialog.c:510
#define SendMessage
Definition: winuser.h:5709
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
void WINAPI DragFinish(HDROP h)
Definition: shellole.c:543
#define WM_DESTROYCLIPBOARD
Definition: winuser.h:1829
#define WM_CREATE
Definition: winuser.h:1590
#define ID_ACCEL
Definition: resources.h:13
#define _istspace
Definition: tchar.h:1504
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define EM_CANUNDO
Definition: winuser.h:1944
#define HIWORD(l)
Definition: typedefs.h:246
#define CMD_HELP_ABOUT_NOTEPAD
Definition: notepad_res.h:64
#define GetWindowTextLength
Definition: winuser.h:5665
VOID DIALOG_HelpAboutNotepad(VOID)
Definition: dialog.c:1191
#define MAKELANGID(p, s)
Definition: nls.h:15
HMONITOR WINAPI MonitorFromRect(LPCRECT, DWORD)
void NOTEPAD_SaveSettingsToRegistry(void)
Definition: settings.c:227
LONG bottom
Definition: windef.h:299
VOID SetFileName(LPCTSTR szFileName)
Definition: main.c:46
#define SWP_NOMOVE
Definition: winuser.h:1229
VOID DIALOG_FileNew(VOID)
Definition: dialog.c:398
static ATOM aFINDMSGSTRING
Definition: main.c:30
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define LoadImage
Definition: winuser.h:5681
#define FR_DIALOGTERM
Definition: commdlg.h:126
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define CMD_TIME_DATE
Definition: notepad_res.h:50
VOID DIALOG_EditWrap(VOID)
Definition: dialog.c:1003
#define LoadIcon
Definition: winuser.h:5679
#define IDNO
Definition: winuser.h:830
TCHAR szFileTitle[MAX_PATH]
Definition: main.h:74
#define WM_ERASEBKGND
Definition: winuser.h:1607
#define WM_SETFOCUS
Definition: winuser.h:1595
#define MF_GRAYED
Definition: winuser.h:129
GLfloat GLfloat p
Definition: glext.h:8902
LONG_PTR LRESULT
Definition: windef.h:209
HWND hEdit
Definition: main.h:62
VOID DIALOG_HelpContents(VOID)
Definition: dialog.c:1186
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:807
VOID DIALOG_ViewStatusBar(VOID)
Definition: dialog.c:1179
static VOID NOTEPAD_InitMenuPopup(HMENU menu, LPARAM index)
Definition: main.c:276
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
HWND hMainWnd
Definition: main.h:60
#define CMD_NEW
Definition: notepad_res.h:36
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
int _tcsncmp(const _TCHAR *s1, const _TCHAR *s2, size_t n)
Definition: tcsncmp.h:9
static VOID NOTEPAD_FindTerm(VOID)
Definition: main.c:245
#define HeapFree(x, y, z)
Definition: compat.h:394
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define LoadString
Definition: winuser.h:5685
FINDREPLACE find
Definition: main.h:84
#define EM_REPLACESEL
Definition: winuser.h:1967
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:438
#define EM_SCROLLCARET
Definition: richedit.h:81
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:96
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29
#define CMD_FONT
Definition: notepad_res.h:58
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:304
#define EN_CHANGE
Definition: winuser.h:1983