ReactOS  0.4.15-dev-318-g99b52df
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  * 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 
33 
35 {
40 }
41 
42 /***********************************************************************
43  *
44  * SetFileName
45  *
46  * Sets Global File Name.
47  */
49 {
51  Globals.szFileTitle[0] = 0;
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  */
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 
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  {
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);
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));
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 
238 
239  while (NOTEPAD_FindNext(pFindReplace, TRUE, bShowAlert))
240  {
241  bShowAlert = FALSE;
242  }
243 }
244 
245 /***********************************************************************
246  *
247  * NOTEPAD_FindTerm
248  */
249 
251 {
253 }
254 
255 /***********************************************************************
256  * Data Initialization
257  */
259 {
261  static const TCHAR txt_files[] = _T("*.txt");
262  static const TCHAR all_files[] = _T("*.*");
263 
265  _tcscpy(p, txt_files);
266  p += ARRAY_SIZE(txt_files);
267 
269  _tcscpy(p, all_files);
270  p += ARRAY_SIZE(all_files);
271  *p = '\0';
273 
276 }
277 
278 /***********************************************************************
279  * Enable/disable items on the menu based on control state
280  */
282 {
283  int enable;
284 
286 
289  if (!Globals.bWrapLongLines)
290  {
293  }
294  EnableMenuItem(menu, CMD_UNDO,
300  EnableMenuItem(menu, CMD_CUT, enable);
303 
307 }
308 
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:
323  break;
324  default:
325  {
327  break;
328  }
329  }
330  }
331  case WM_LBUTTONUP:
332  {
334  break;
335  }
336  }
338 }
339 
340 /***********************************************************************
341  *
342  * NOTEPAD_WndProc
343  */
344 static LRESULT
345 WINAPI
347 {
348  switch (msg)
349  {
350 
351  case WM_CREATE:
353 
354  // For now, the "Help" dialog is disabled due to the lack of HTML Help support
356  break;
357 
358  case WM_COMMAND:
361  if ((HIWORD(wParam) == EN_CHANGE))
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)
374  if (Globals.hDevMode)
376  if (Globals.hDevNames)
379  }
380  break;
381 
382  case WM_QUERYENDSESSION:
383  if (DoCloseFile()) {
384  return 1;
385  }
386  break;
387 
388  case WM_DESTROY:
391  PostQuitMessage(0);
392  break;
393 
394  case WM_SIZE:
395  {
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),
416 
417  if (hdwp == NULL)
418  break;
419 
420  hdwp = DeferWindowPos(hdwp,
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
434  NULL,
435  0,
436  0,
437  LOWORD(lParam),
438  HIWORD(lParam),
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:
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:
467  break;
468  default:
469  if (msg == aFINDMSGSTRING)
470  {
471  FINDREPLACE *pFindReplace = (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)
482  break;
483  }
484 
485  return DefWindowProc(hWnd, msg, wParam, lParam);
486  }
487  return 0;
488 }
489 
490 static int AlertFileDoesNotExist(LPCTSTR szFileName)
491 {
493  szFileName,
495 }
496 
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 */
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;
553  }
554  }
555 
556  if (file_exists)
557  {
560  if (opt_print)
561  {
563  return FALSE;
564  }
565  }
566  else
567  {
568  switch (AlertFileDoesNotExist(file_name)) {
569  case IDYES:
571  break;
572 
573  case IDNO:
574  break;
575  }
576  }
577  }
578 
579  return TRUE;
580 }
581 
582 /***********************************************************************
583  *
584  * WinMain
585  */
587 {
588  MSG msg;
589  HACCEL hAccel;
590  WNDCLASSEX wndclass;
591  HMONITOR monitor;
593  INT x, y;
594 
595  static const TCHAR className[] = _T("Notepad");
596  static const TCHAR winName[] = _T("Notepad");
597 
598  switch (GetUserDefaultUILanguage())
599  {
602  break;
603 
604  default:
605  break;
606  }
607 
609 
611 
612  ZeroMemory(&Globals, sizeof(Globals));
615 
616  ZeroMemory(&wndclass, sizeof(wndclass));
617  wndclass.cbSize = sizeof(wndclass);
618  wndclass.lpfnWndProc = NOTEPAD_WndProc;
619  wndclass.hInstance = Globals.hInstance;
621  wndclass.hCursor = LoadCursor(0, IDC_ARROW);
622  wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
624  wndclass.lpszClassName = className;
625  wndclass.hIconSm = (HICON)LoadImage(hInstance,
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 
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,
651  x,
652  y,
655  NULL,
656  NULL,
658  NULL);
659  if (!Globals.hMainWnd)
660  {
661  ShowLastError();
662  ExitProcess(1);
663  }
664 
666 
668  DIALOG_FileNew();
669 
670  ShowWindow(Globals.hMainWnd, show);
673 
675 
677  {
678  return 0;
679  }
680 
682 
683  while (GetMessage(&msg, 0, 0, 0))
684  {
687  {
690  }
691  }
692  return (int) msg.wParam;
693 }
#define FR_FINDNEXT
Definition: commdlg.h:131
HWND hFindReplaceDlg
Definition: main.h:57
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE prev, LPTSTR cmdline, int show)
Definition: main.c:586
#define CallWindowProc
Definition: winuser.h:5710
VOID DIALOG_Search(VOID)
Definition: dialog.c:1078
#define TranslateAccelerator
Definition: winuser.h:5835
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DispatchMessage
Definition: winuser.h:5740
LANGID WINAPI GetUserDefaultUILanguage(void)
Definition: lang.c:806
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:3185
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
NOTEPAD_GLOBALS Globals
Definition: main.c:31
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define RegisterClassEx
Definition: winuser.h:5812
BOOL WINAPI IsClipboardFormatAvailable(_In_ UINT)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define LAYOUT_RTL
Definition: wingdi.h:1370
#define WM_CHAR
Definition: winuser.h:1699
HCURSOR hCursor
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3178
#define CreateWindow
Definition: winuser.h:5729
#define IDYES
Definition: winuser.h:829
#define CMD_WRAP
Definition: notepad_res.h:57
VOID DIALOG_FileExit(VOID)
Definition: dialog.c:781
static VOID NOTEPAD_InitData(VOID)
Definition: main.c:258
LPCSTR lpszClassName
Definition: winuser.h:3186
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:1728
VOID DIALOG_EditSelectAll(VOID)
Definition: dialog.c:811
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
#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:307
LPSTR lpstrFindWhat
Definition: commdlg.h:307
#define VK_LEFT
Definition: winuser.h:2199
HGLOBAL hDevNames
Definition: main.h:63
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1487
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define CMD_EXIT
Definition: resources.h:17
#define CMD_SEARCH
Definition: notepad_res.h:52
HWND WINAPI SetFocus(_In_opt_ HWND)
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_DOWN
Definition: winuser.h:2202
WNDPROC EditProc
Definition: main.h:81
TCHAR * cmdline
Definition: stretchblt.cpp:32
HGLOBAL hDevMode
Definition: main.h:62
HICON hIconSm
Definition: winuser.h:3187
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1232
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
VOID DIALOG_EditCopy(VOID)
Definition: dialog.c:796
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:143
BOOL HasFileExtension(LPCTSTR szFilename)
Definition: dialog.c:165
#define IsDialogMessage
Definition: winuser.h:5784
#define CMD_GOTO
Definition: notepad_res.h:55
LONG right
Definition: windef.h:308
#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
#define DWORD
Definition: nt_native.h:44
int32_t INT
Definition: typedefs.h:57
#define LANG_HEBREW
Definition: nls.h:67
static BOOLEAN bSuccess
Definition: drive.cpp:419
#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:5773
#define STRING_TEXT_FILES_TXT
Definition: notepad_res.h:80
struct _test_info info[]
Definition: SetCursorPos.c:19
HINSTANCE hInstance
Definition: main.h:55
#define EM_GETSEL
Definition: winuser.h:1979
#define FR_REPLACEALL
Definition: commdlg.h:143
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define CMD_STATUSBAR
Definition: notepad_res.h:60
#define STRING_DOESNOTEXIST
Definition: notepad_res.h:83
#define LoadAccelerators
Definition: winuser.h:5785
TCHAR szFileName[MAX_PATH]
Definition: main.h:69
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU hMenu
Definition: main.h:61
void WINAPI SHAddToRecentDocs(UINT uFlags, LPCVOID pv)
Definition: shellord.c:723
#define VK_UP
Definition: winuser.h:2200
#define STRING_NOTEPAD
Definition: notepad_res.h:74
#define MB_YESNO
Definition: winuser.h:811
HINSTANCE hInstance
Definition: winuser.h:3181
static const WCHAR szText[]
Definition: dialog.c:139
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:154
HACCEL hAccel
Definition: main.c:47
unsigned int BOOL
Definition: ntddk_ex.h:94
static VOID DoOpenFile(PINFO pInfo)
Definition: connectdialog.c:34
static BOOL NOTEPAD_FindTextAt(FINDREPLACE *pFindReplace, LPCTSTR pszText, int iTextLength, DWORD dwPosition)
Definition: main.c:109
#define _tcsnicmp
Definition: xmlstorage.h:207
DWORD Flags
Definition: commdlg.h:306
static VOID NOTEPAD_ReplaceAll(FINDREPLACE *pFindReplace)
Definition: main.c:233
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
BOOL DoCloseFile(VOID)
Definition: dialog.c:322
#define WM_DROPFILES
Definition: winuser.h:1807
VOID DIALOG_EditDelete(VOID)
Definition: dialog.c:806
BOOL bShowStatusBar
Definition: main.h:66
#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:1218
#define CMD_OPEN
Definition: resources.h:15
smooth NULL
Definition: ftsmooth.c:416
Definition: getopt.h:108
#define WM_KEYDOWN
Definition: winuser.h:1697
LONG_PTR LPARAM
Definition: windef.h:208
UINT cbSize
Definition: winuser.h:3176
#define GetFileTitle
Definition: commdlg.h:664
#define CMD_REPLACE
Definition: notepad_res.h:54
static int NOTEPAD_MenuCommand(WPARAM wParam)
Definition: main.c:64
GLuint index
Definition: glext.h:6031
VOID DIALOG_SelectFont(VOID)
Definition: dialog.c:1028
HFONT hFont
Definition: main.h:60
VOID DIALOG_GoTo(VOID)
Definition: dialog.c:1132
#define STRING_ALL_FILES
Definition: notepad_res.h:79
HBRUSH hbrBackground
Definition: winuser.h:3184
VOID DIALOG_SearchNext(VOID)
Definition: dialog.c:1083
#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:910
static int AlertFileDoesNotExist(LPCTSTR szFileName)
Definition: main.c:490
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1720
RECT main_rect
Definition: main.h:82
#define MF_CHECKED
Definition: winuser.h:132
char TCHAR
Definition: xmlstorage.h:189
#define FINDMSGSTRING
Definition: commdlg.h:653
HWND hStatusBar
Definition: main.h:59
#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
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:404
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:801
VOID DIALOG_FileOpen(VOID)
Definition: dialog.c:418
#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:1174
#define WINAPI
Definition: msvc.h:6
#define EM_SETSEL
Definition: winuser.h:2000
#define WM_KEYUP
Definition: winuser.h:1698
VOID DIALOG_FilePrint(VOID)
Definition: dialog.c:566
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:101
HICON hIcon
Definition: winuser.h:3182
#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:346
#define _sntprintf
Definition: xmlstorage.h:201
#define CMD_UNDO
Definition: notepad_res.h:44
TCHAR szFilter[2 *MAX_STRING_LEN+100]
Definition: main.h:71
#define MessageBox
Definition: winuser.h:5797
#define WM_COMMAND
Definition: winuser.h:1722
#define MF_UNCHECKED
Definition: winuser.h:204
#define EN_HSCROLL
Definition: winuser.h:2006
#define LoadCursor
Definition: winuser.h:5787
#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:2201
LPSTR lpstrReplaceWith
Definition: commdlg.h:308
#define RegisterWindowMessage
Definition: winuser.h:5815
#define EN_VSCROLL
Definition: winuser.h:2011
BOOL bWrapLongLines
Definition: main.h:65
#define FR_WHOLEWORD
Definition: commdlg.h:145
int all_files
Definition: mkisofs.c:132
#define lstrlen
Definition: winbase.h:3716
GLboolean enable
Definition: glext.h:11120
VOID DIALOG_EditUndo(VOID)
Definition: dialog.c:786
#define ARRAY_SIZE(a)
Definition: main.h:24
static BOOL HandleCommandLine(LPTSTR cmdline)
Definition: main.c:497
#define IDI_NPICON
Definition: notepad_res.h:32
#define WM_LBUTTONUP
Definition: winuser.h:1759
#define MAX_STRING_LEN
Definition: main.c:73
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SHARD_PATHW
Definition: shlobj.h:1103
unsigned int UINT
Definition: ndis.h:50
#define MB_OK
Definition: winuser.h:784
#define GetMessage
Definition: winuser.h:5765
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
VOID DIALOG_Replace(VOID)
Definition: dialog.c:1091
VOID DIALOG_EditCut(VOID)
Definition: dialog.c:791
#define FR_DOWN
Definition: commdlg.h:127
static LPCWSTR file_name
Definition: protocol.c:147
#define DragQueryFile
Definition: shellapi.h:682
#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:34
BOOL DIALOG_FileSaveAs(VOID)
Definition: dialog.c:519
#define SendMessage
Definition: winuser.h:5818
_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:1850
#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:1965
#define HIWORD(l)
Definition: typedefs.h:246
#define CMD_HELP_ABOUT_NOTEPAD
Definition: notepad_res.h:64
#define GetWindowTextLength
Definition: winuser.h:5774
VOID DIALOG_HelpAboutNotepad(VOID)
Definition: dialog.c:1200
#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:309
VOID SetFileName(LPCTSTR szFileName)
Definition: main.c:48
#define SWP_NOMOVE
Definition: winuser.h:1229
VOID DIALOG_FileNew(VOID)
Definition: dialog.c:407
static ATOM aFINDMSGSTRING
Definition: main.c:32
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define LoadImage
Definition: winuser.h:5790
#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:1012
#define LoadIcon
Definition: winuser.h:5788
#define IDNO
Definition: winuser.h:830
TCHAR szFileTitle[MAX_PATH]
Definition: main.h:70
#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:58
VOID DIALOG_HelpContents(VOID)
Definition: dialog.c:1195
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:816
VOID DIALOG_ViewStatusBar(VOID)
Definition: dialog.c:1188
static VOID NOTEPAD_InitMenuPopup(HMENU menu, LPARAM index)
Definition: main.c:281
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:56
#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:250
#define HeapFree(x, y, z)
Definition: compat.h:403
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define LoadString
Definition: winuser.h:5794
FINDREPLACE find
Definition: main.h:80
#define EM_REPLACESEL
Definition: winuser.h:1988
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:447
#define EM_SCROLLCARET
Definition: richedit.h:81
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:102
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define CMD_FONT
Definition: notepad_res.h:58
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:309
#define EN_CHANGE
Definition: winuser.h:2004