ReactOS  0.4.15-dev-5142-g967f5b9
dialog.c
Go to the documentation of this file.
1 /*
2  * Notepad (dialog.c)
3  *
4  * Copyright 1998,99 Marcel Baur <mbaur@g26.ethz.ch>
5  * Copyright 2002 Sylvain Petreolle <spetreolle@yahoo.fr>
6  * Copyright 2002 Andriy Palamarchuk
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "notepad.h"
24 
25 #include <assert.h>
26 #include <commctrl.h>
27 #include <strsafe.h>
28 
30 
31 static const TCHAR helpfile[] = _T("notepad.hlp");
32 static const TCHAR empty_str[] = _T("");
33 static const TCHAR szDefaultExt[] = _T("txt");
34 static const TCHAR txt_files[] = _T("*.txt");
35 
36 /* Status bar parts index */
37 #define SBPART_CURPOS 0
38 #define SBPART_EOLN 1
39 #define SBPART_ENCODING 2
40 
41 /* Line endings - string resource ID mapping table */
42 static UINT EolnToStrId[] = {
44  STRING_LF,
45  STRING_CR
46 };
47 
48 /* Encoding - string resource ID mapping table */
49 static UINT EncToStrId[] = {
55 };
56 
58 
60 {
62  if (error != NO_ERROR)
63  {
64  LPTSTR lpMsgBuf = NULL;
66 
68 
70  NULL,
71  error,
72  0,
73  (LPTSTR) &lpMsgBuf,
74  0,
75  NULL);
76 
77  MessageBox(NULL, lpMsgBuf, szTitle, MB_OK | MB_ICONERROR);
78  LocalFree(lpMsgBuf);
79  }
80 }
81 
87 void UpdateWindowCaption(BOOL clearModifyAlert)
88 {
89  TCHAR szCaption[MAX_STRING_LEN];
90  TCHAR szNotepad[MAX_STRING_LEN];
91  TCHAR szFilename[MAX_STRING_LEN];
92  BOOL isModified;
93 
94  if (clearModifyAlert)
95  {
96  /* When a file is being opened or created, there is no need to have
97  * the edited flag shown when the file has not been edited yet. */
98  isModified = FALSE;
99  }
100  else
101  {
102  /* Check whether the user has modified the file or not. If we are
103  * in the same state as before, don't change the caption. */
104  isModified = !!SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0);
105  if (isModified == Globals.bWasModified)
106  return;
107  }
108 
109  /* Remember the state for later calls */
110  Globals.bWasModified = isModified;
111 
112  /* Load the name of the application */
113  LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad));
114 
115  /* Determine if the file has been saved or if this is a new file */
116  if (Globals.szFileTitle[0] != 0)
117  StringCchCopy(szFilename, ARRAY_SIZE(szFilename), Globals.szFileTitle);
118  else
119  LoadString(Globals.hInstance, STRING_UNTITLED, szFilename, ARRAY_SIZE(szFilename));
120 
121  /* Update the window caption based upon whether the user has modified the file or not */
122  StringCbPrintf(szCaption, sizeof(szCaption), _T("%s%s - %s"),
123  (isModified ? _T("*") : _T("")), szFilename, szNotepad);
124 
125  SetWindowText(Globals.hMainWnd, szCaption);
126 }
127 
129 {
130  static const int defaultWidths[] = {120, 120, 120};
131  RECT rcStatusBar;
132  int parts[3];
133 
134  GetClientRect(Globals.hStatusBar, &rcStatusBar);
135 
136  parts[0] = rcStatusBar.right - (defaultWidths[1] + defaultWidths[2]);
137  parts[1] = rcStatusBar.right - defaultWidths[2];
138  parts[2] = -1; // the right edge of the status bar
139 
140  parts[0] = max(parts[0], defaultWidths[0]);
141  parts[1] = max(parts[1], defaultWidths[0] + defaultWidths[1]);
142 
144 }
145 
147 {
148  WCHAR szText[128];
149 
150  LoadStringW(Globals.hInstance, EolnToStrId[Globals.iEoln], szText, ARRAY_SIZE(szText));
151 
152  SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_EOLN, (LPARAM)szText);
153 }
154 
156 {
157  WCHAR szText[128] = L"";
158 
159  if (Globals.encFile != ENCODING_AUTO)
160  {
161  LoadStringW(Globals.hInstance, EncToStrId[Globals.encFile], szText, ARRAY_SIZE(szText));
162  }
163 
164  SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_ENCODING, (LPARAM)szText);
165 }
166 
167 int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
168 {
169  TCHAR szMessage[MAX_STRING_LEN];
170  TCHAR szResource[MAX_STRING_LEN];
171 
172  /* Load and format szMessage */
173  LoadString(Globals.hInstance, formatId, szResource, ARRAY_SIZE(szResource));
174  _sntprintf(szMessage, ARRAY_SIZE(szMessage), szResource, szString);
175 
176  /* Load szCaption */
178  LoadString(Globals.hInstance, STRING_ERROR, szResource, ARRAY_SIZE(szResource));
179  else
180  LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource));
181 
182  /* Display Modal Dialog */
183  // if (hParent == NULL)
184  // hParent = Globals.hMainWnd;
185  return MessageBox(hParent, szMessage, szResource, dwFlags);
186 }
187 
188 static void AlertFileNotFound(LPCTSTR szFileName)
189 {
191 }
192 
193 static int AlertFileNotSaved(LPCTSTR szFileName)
194 {
195  TCHAR szUntitled[MAX_STRING_LEN];
196 
197  LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, ARRAY_SIZE(szUntitled));
198 
200  szFileName[0] ? szFileName : szUntitled,
202 }
203 
204 static void AlertPrintError(void)
205 {
206  TCHAR szUntitled[MAX_STRING_LEN];
207 
208  LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, ARRAY_SIZE(szUntitled));
209 
211  Globals.szFileName[0] ? Globals.szFileName : szUntitled,
213 }
214 
221 {
223  HANDLE hFile;
224 
225  hFile = FindFirstFile(szFilename, &entry);
226  FindClose(hFile);
227 
228  return (hFile != INVALID_HANDLE_VALUE);
229 }
230 
232 {
233  LPCTSTR s;
234 
235  s = _tcsrchr(szFilename, _T('\\'));
236  if (s)
237  szFilename = s;
238  return _tcsrchr(szFilename, _T('.')) != NULL;
239 }
240 
242 {
243  DWORD dwStart = 0;
244  DWORD dwEnd = 0;
245 
246  SendMessage(hWnd, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
247 
248  return dwEnd - dwStart;
249 }
250 
252 {
253  DWORD dwStart = 0;
254  DWORD dwEnd = 0;
255  DWORD dwSize;
256  HRESULT hResult;
257  LPTSTR lpTemp;
258 
259  if (!lpString)
260  {
261  return 0;
262  }
263 
264  SendMessage(hWnd, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
265 
266  if (dwStart == dwEnd)
267  {
268  return 0;
269  }
270 
272  lpTemp = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(TCHAR));
273  if (!lpTemp)
274  {
275  return 0;
276  }
277 
278  dwSize = GetWindowText(hWnd, lpTemp, dwSize);
279 
280  if (!dwSize)
281  {
282  HeapFree(GetProcessHeap(), 0, lpTemp);
283  return 0;
284  }
285 
286  hResult = StringCchCopyN(lpString, nMaxCount, lpTemp + dwStart, dwEnd - dwStart);
287  HeapFree(GetProcessHeap(), 0, lpTemp);
288 
289  switch (hResult)
290  {
291  case S_OK:
292  {
293  return dwEnd - dwStart;
294  }
295 
297  {
298  return nMaxCount - 1;
299  }
300 
301  default:
302  {
303  return 0;
304  }
305  }
306 }
307 
308 static RECT
310 {
311  int iLogPixelsX, iLogPixelsY;
312  int iHorzRes, iVertRes;
313  int iPhysPageX, iPhysPageY, iPhysPageW, iPhysPageH;
314  RECT rcPrintRect;
315 
316  iPhysPageX = GetDeviceCaps(hdc, PHYSICALOFFSETX);
317  iPhysPageY = GetDeviceCaps(hdc, PHYSICALOFFSETY);
318  iPhysPageW = GetDeviceCaps(hdc, PHYSICALWIDTH);
319  iPhysPageH = GetDeviceCaps(hdc, PHYSICALHEIGHT);
320  iLogPixelsX = GetDeviceCaps(hdc, LOGPIXELSX);
321  iLogPixelsY = GetDeviceCaps(hdc, LOGPIXELSY);
322  iHorzRes = GetDeviceCaps(hdc, HORZRES);
323  iVertRes = GetDeviceCaps(hdc, VERTRES);
324 
325  rcPrintRect.left = (margins.left * iLogPixelsX / 2540) - iPhysPageX;
326  rcPrintRect.top = (margins.top * iLogPixelsY / 2540) - iPhysPageY;
327  rcPrintRect.right = iHorzRes - (((margins.left * iLogPixelsX / 2540) - iPhysPageX) + ((margins.right * iLogPixelsX / 2540) - (iPhysPageW - iPhysPageX - iHorzRes)));
328  rcPrintRect.bottom = iVertRes - (((margins.top * iLogPixelsY / 2540) - iPhysPageY) + ((margins.bottom * iLogPixelsY / 2540) - (iPhysPageH - iPhysPageY - iVertRes)));
329 
330  return rcPrintRect;
331 }
332 
334 {
335  BOOL bRet = TRUE;
336  HANDLE hFile;
337  LPTSTR pTemp;
338  DWORD size;
339 
343  {
344  ShowLastError();
345  return FALSE;
346  }
347 
348  size = GetWindowTextLength(Globals.hEdit) + 1;
349  pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(*pTemp));
350  if (!pTemp)
351  {
353  ShowLastError();
354  return FALSE;
355  }
356  size = GetWindowText(Globals.hEdit, pTemp, size);
357 
358  if (size)
359  {
360  if (!WriteText(hFile, (LPWSTR)pTemp, size, Globals.encFile, Globals.iEoln))
361  {
362  ShowLastError();
363  bRet = FALSE;
364  }
365  else
366  {
368  bRet = TRUE;
369  }
370  }
371 
373  HeapFree(GetProcessHeap(), 0, pTemp);
374 
375  if (bRet)
376  {
377  SetFileName(Globals.szFileName);
378  }
379 
380  return bRet;
381 }
382 
389 {
390  int nResult;
391 
392  if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
393  {
394  /* prompt user to save changes */
395  nResult = AlertFileNotSaved(Globals.szFileName);
396  switch (nResult)
397  {
398  case IDYES:
399  if(!DIALOG_FileSave())
400  return FALSE;
401  break;
402 
403  case IDNO:
404  break;
405 
406  case IDCANCEL:
407  return FALSE;
408 
409  default:
410  return FALSE;
411  }
412  }
413 
416 
417  return TRUE;
418 }
419 
421 {
422  static const TCHAR dotlog[] = _T(".LOG");
423  HANDLE hFile;
424  LPTSTR pszText = NULL;
425  DWORD dwTextLen;
426  TCHAR log[5];
427 
428  /* Close any files and prompt to save changes */
429  if (!DoCloseFile())
430  return;
431 
435  {
436  ShowLastError();
437  goto done;
438  }
439 
440  if (!ReadText(hFile, (LPWSTR *)&pszText, &dwTextLen, &Globals.encFile, &Globals.iEoln))
441  {
442  ShowLastError();
443  goto done;
444  }
445  SetWindowText(Globals.hEdit, pszText);
446 
448  SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
449  SetFocus(Globals.hEdit);
450 
451  /* If the file starts with .LOG, add a time/date at the end and set cursor after
452  * See http://support.microsoft.com/?kbid=260563
453  */
454  if (GetWindowText(Globals.hEdit, log, ARRAY_SIZE(log)) && !_tcscmp(log, dotlog))
455  {
456  static const TCHAR lf[] = _T("\r\n");
461  }
462 
463  SetFileName(szFileName);
466 
467  /* Update line endings and encoding on the status bar */
470 
471 done:
474  if (pszText)
475  HeapFree(GetProcessHeap(), 0, pszText);
476 }
477 
479 {
480  /* Close any files and prompt to save changes */
481  if (DoCloseFile()) {
483  SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
484  SetFocus(Globals.hEdit);
486  }
487 }
488 
490 {
491  TCHAR pszNotepadExe[MAX_PATH];
492  GetModuleFileName(NULL, pszNotepadExe, ARRAYSIZE(pszNotepadExe));
493  ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL);
494 }
495 
497 {
498  OPENFILENAME openfilename;
500 
501  ZeroMemory(&openfilename, sizeof(openfilename));
502 
503  if (Globals.szFileName[0] == 0)
505  else
506  _tcscpy(szPath, Globals.szFileName);
507 
508  openfilename.lStructSize = sizeof(openfilename);
509  openfilename.hwndOwner = Globals.hMainWnd;
510  openfilename.hInstance = Globals.hInstance;
511  openfilename.lpstrFilter = Globals.szFilter;
512  openfilename.lpstrFile = szPath;
513  openfilename.nMaxFile = ARRAY_SIZE(szPath);
515  openfilename.lpstrDefExt = szDefaultExt;
516 
517  if (GetOpenFileName(&openfilename)) {
518  if (FileExists(openfilename.lpstrFile))
519  DoOpenFile(openfilename.lpstrFile);
520  else
521  AlertFileNotFound(openfilename.lpstrFile);
522  }
523 }
524 
526 {
527  if (Globals.szFileName[0] == 0)
528  {
529  return DIALOG_FileSaveAs();
530  }
531  else if (DoSaveFile())
532  {
534  return TRUE;
535  }
536  return FALSE;
537 }
538 
539 static UINT_PTR
540 CALLBACK
542 {
543  TCHAR szText[128];
544  HWND hCombo;
545 
547 
548  switch(msg)
549  {
550  case WM_INITDIALOG:
551  hCombo = GetDlgItem(hDlg, ID_ENCODING);
552 
554  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
555 
557  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
558 
560  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
561 
563  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
564 
566  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
567 
568  SendMessage(hCombo, CB_SETCURSEL, Globals.encFile, 0);
569 
570  hCombo = GetDlgItem(hDlg, ID_EOLN);
571 
573  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
574 
575  LoadString(Globals.hInstance, STRING_LF, szText, ARRAY_SIZE(szText));
576  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
577 
578  LoadString(Globals.hInstance, STRING_CR, szText, ARRAY_SIZE(szText));
579  SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
580 
581  SendMessage(hCombo, CB_SETCURSEL, Globals.iEoln, 0);
582  break;
583 
584  case WM_NOTIFY:
585  if (((NMHDR *) lParam)->code == CDN_FILEOK)
586  {
587  hCombo = GetDlgItem(hDlg, ID_ENCODING);
588  if (hCombo)
589  Globals.encFile = (ENCODING) SendMessage(hCombo, CB_GETCURSEL, 0, 0);
590 
591  hCombo = GetDlgItem(hDlg, ID_EOLN);
592  if (hCombo)
593  Globals.iEoln = (int) SendMessage(hCombo, CB_GETCURSEL, 0, 0);
594  }
595  break;
596  }
597  return 0;
598 }
599 
601 {
602  OPENFILENAME saveas;
604 
605  ZeroMemory(&saveas, sizeof(saveas));
606 
607  if (Globals.szFileName[0] == 0)
609  else
610  _tcscpy(szPath, Globals.szFileName);
611 
612  saveas.lStructSize = sizeof(OPENFILENAME);
613  saveas.hwndOwner = Globals.hMainWnd;
614  saveas.hInstance = Globals.hInstance;
615  saveas.lpstrFilter = Globals.szFilter;
616  saveas.lpstrFile = szPath;
617  saveas.nMaxFile = ARRAY_SIZE(szPath);
620  saveas.lpstrDefExt = szDefaultExt;
623 
624  if (GetSaveFileName(&saveas))
625  {
626  /* HACK: Because in ROS, Save-As boxes don't check the validity
627  * of file names and thus, here, szPath can be invalid !! We only
628  * see its validity when we call DoSaveFile()... */
630  if (DoSaveFile())
631  {
633 
634  /* Update line endings and encoding on the status bar */
637 
638  return TRUE;
639  }
640  else
641  {
642  SetFileName(_T(""));
643  return FALSE;
644  }
645  }
646  else
647  {
648  return FALSE;
649  }
650 }
651 
653 {
654  DOCINFO di;
655  TEXTMETRIC tm;
656  PRINTDLG printer;
657  SIZE szMetric;
658  int border;
659  int xLeft, yTop, pagecount, dopage, copycount;
660  unsigned int i;
661  LOGFONT hdrFont;
662  HFONT font, old_font=0;
663  DWORD size;
664  LPTSTR pTemp;
665  static const TCHAR times_new_roman[] = _T("Times New Roman");
666  RECT rcPrintRect;
667 
668  /* Get a small font and print some header info on each page */
669  ZeroMemory(&hdrFont, sizeof(hdrFont));
670  hdrFont.lfHeight = 100;
671  hdrFont.lfWeight = FW_BOLD;
672  hdrFont.lfCharSet = ANSI_CHARSET;
675  hdrFont.lfQuality = PROOF_QUALITY;
677  _tcscpy(hdrFont.lfFaceName, times_new_roman);
678 
679  font = CreateFontIndirect(&hdrFont);
680 
681  /* Get Current Settings */
682  ZeroMemory(&printer, sizeof(printer));
683  printer.lStructSize = sizeof(printer);
684  printer.hwndOwner = Globals.hMainWnd;
685  printer.hInstance = Globals.hInstance;
686 
687  /* Set some default flags */
688  printer.Flags = PD_RETURNDC | PD_SELECTION;
689 
690  /* Disable the selection radio button if there is no text selected */
691  if (!GetSelectionTextLength(Globals.hEdit))
692  {
693  printer.Flags = printer.Flags | PD_NOSELECTION;
694  }
695 
696  printer.nFromPage = 0;
697  printer.nMinPage = 1;
698  /* we really need to calculate number of pages to set nMaxPage and nToPage */
699  printer.nToPage = (WORD)-1;
700  printer.nMaxPage = (WORD)-1;
701 
702  /* Let commdlg manage copy settings */
703  printer.nCopies = (WORD)PD_USEDEVMODECOPIES;
704 
705  printer.hDevMode = Globals.hDevMode;
706  printer.hDevNames = Globals.hDevNames;
707 
708  if (!PrintDlg(&printer))
709  {
711  return;
712  }
713 
714  Globals.hDevMode = printer.hDevMode;
715  Globals.hDevNames = printer.hDevNames;
716 
717  assert(printer.hDC != 0);
718 
719  /* initialize DOCINFO */
720  di.cbSize = sizeof(DOCINFO);
721  di.lpszDocName = Globals.szFileTitle;
722  di.lpszOutput = NULL;
723  di.lpszDatatype = NULL;
724  di.fwType = 0;
725 
726  if (StartDoc(printer.hDC, &di) <= 0)
727  {
729  return;
730  }
731 
732 
733  /* Get the file text */
734  if (printer.Flags & PD_SELECTION)
735  {
736  size = GetSelectionTextLength(Globals.hEdit) + 1;
737  }
738  else
739  {
740  size = GetWindowTextLength(Globals.hEdit) + 1;
741  }
742 
743  pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(TCHAR));
744  if (!pTemp)
745  {
746  EndDoc(printer.hDC);
748  ShowLastError();
749  return;
750  }
751 
752  if (printer.Flags & PD_SELECTION)
753  {
754  size = GetSelectionText(Globals.hEdit, pTemp, size);
755  }
756  else
757  {
758  size = GetWindowText(Globals.hEdit, pTemp, size);
759  }
760 
761  /* Get the current printing area */
762  rcPrintRect = GetPrintingRect(printer.hDC, Globals.lMargins);
763 
764  /* Ensure that each logical unit maps to one pixel */
765  SetMapMode(printer.hDC, MM_TEXT);
766 
767  /* Needed to get the correct height of a text line */
768  GetTextMetrics(printer.hDC, &tm);
769 
770  border = 15;
771  for (copycount=1; copycount <= printer.nCopies; copycount++) {
772  i = 0;
773  pagecount = 1;
774  do {
775  /* Don't start a page if none of the conditions below are true */
776  dopage = 0;
777 
778  /* The user wants to print the current selection */
779  if (printer.Flags & PD_SELECTION)
780  {
781  dopage = 1;
782  }
783 
784  /* The user wants to print the entire document */
785  if (!(printer.Flags & PD_PAGENUMS) && !(printer.Flags & PD_SELECTION))
786  {
787  dopage = 1;
788  }
789 
790  /* The user wants to print a specified range of pages */
791  if ((pagecount >= printer.nFromPage && pagecount <= printer.nToPage))
792  {
793  dopage = 1;
794  }
795 
796  old_font = SelectObject(printer.hDC, font);
797 
798  if (dopage) {
799  if (StartPage(printer.hDC) <= 0) {
800  SelectObject(printer.hDC, old_font);
801  EndDoc(printer.hDC);
802  DeleteDC(printer.hDC);
803  HeapFree(GetProcessHeap(), 0, pTemp);
805  AlertPrintError();
806  return;
807  }
808 
809  SetViewportOrgEx(printer.hDC, rcPrintRect.left, rcPrintRect.top, NULL);
810 
811  /* Write a rectangle and header at the top of each page */
812  Rectangle(printer.hDC, border, border, rcPrintRect.right - border, border + tm.tmHeight * 2);
813  /* I don't know what's up with this TextOut command. This comes out
814  kind of mangled.
815  */
816  TextOut(printer.hDC,
817  border * 2,
818  border + tm.tmHeight / 2,
819  Globals.szFileTitle,
820  lstrlen(Globals.szFileTitle));
821  }
822 
823  /* The starting point for the main text */
824  xLeft = 0;
825  yTop = border + tm.tmHeight * 4;
826 
827  SelectObject(printer.hDC, old_font);
828 
829  /* Since outputting strings is giving me problems, output the main
830  * text one character at a time. */
831  do {
832  if (pTemp[i] == '\n') {
833  xLeft = 0;
834  yTop += tm.tmHeight;
835  }
836  else if (pTemp[i] != '\r') {
837  if (dopage)
838  TextOut(printer.hDC, xLeft, yTop, &pTemp[i], 1);
839 
840  /* We need to get the width for each individual char, since a proportional font may be used */
841  GetTextExtentPoint32(printer.hDC, &pTemp[i], 1, &szMetric);
842  xLeft += szMetric.cx;
843 
844  /* Insert a line break if the current line does not fit into the printing area */
845  if (xLeft > rcPrintRect.right)
846  {
847  xLeft = 0;
848  yTop = yTop + tm.tmHeight;
849  }
850  }
851  } while (i++ < size && yTop < rcPrintRect.bottom);
852 
853  if (dopage)
854  EndPage(printer.hDC);
855  pagecount++;
856  } while (i < size);
857  }
858 
859  if (old_font != 0)
860  SelectObject(printer.hDC, old_font);
861  EndDoc(printer.hDC);
862  DeleteDC(printer.hDC);
863  HeapFree(GetProcessHeap(), 0, pTemp);
865 }
866 
868 {
870 }
871 
873 {
874  SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
875 }
876 
878 {
879  SendMessage(Globals.hEdit, WM_CUT, 0, 0);
880 }
881 
883 {
884  SendMessage(Globals.hEdit, WM_COPY, 0, 0);
885 }
886 
888 {
889  SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
890 }
891 
893 {
894  SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
895 }
896 
898 {
899  SendMessage(Globals.hEdit, EM_SETSEL, 0, (LPARAM)-1);
900 }
901 
903 {
904  SYSTEMTIME st;
905  TCHAR szDate[MAX_STRING_LEN];
906  TCHAR szText[MAX_STRING_LEN * 2 + 2];
907 
908  GetLocalTime(&st);
909 
911  _tcscpy(szText, szDate);
912  _tcscat(szText, _T(" "));
914  _tcscat(szText, szDate);
915  SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szText);
916 }
917 
919 {
920  RECT rc;
921  RECT rcstatus;
922  BOOL bStatusBarVisible;
923 
924  /* Check if status bar object already exists. */
925  if (Globals.hStatusBar == NULL)
926  {
927  /* Try to create the status bar */
929  NULL,
932 
933  if (Globals.hStatusBar == NULL)
934  {
935  ShowLastError();
936  return;
937  }
938 
939  /* Load the string for formatting column/row text output */
940  LoadString(Globals.hInstance, STRING_LINE_COLUMN, Globals.szStatusBarLineCol, MAX_PATH - 1);
941  }
942 
943  /* Set status bar visiblity according to the settings. */
944  if ((Globals.bWrapLongLines != FALSE) || (Globals.bShowStatusBar == FALSE))
945  {
946  bStatusBarVisible = FALSE;
947  ShowWindow(Globals.hStatusBar, SW_HIDE);
948  }
949  else
950  {
951  bStatusBarVisible = TRUE;
952  ShowWindow(Globals.hStatusBar, SW_SHOW);
953  SendMessage(Globals.hStatusBar, WM_SIZE, 0, 0);
954  }
955 
956  /* Set check state in show status bar item. */
957  if (bStatusBarVisible)
958  {
960  }
961  else
962  {
964  }
965 
966  /* Update menu mar with the previous changes */
968 
969  /* Sefety test is edit control exists */
970  if (Globals.hEdit != NULL)
971  {
972  /* Retrieve the sizes of the controls */
974  GetClientRect(Globals.hStatusBar, &rcstatus);
975 
976  /* If status bar is currently visible, update dimensions of edit control */
977  if (bStatusBarVisible)
978  rc.bottom -= (rcstatus.bottom - rcstatus.top);
979 
980  /* Resize edit control to right size. */
981  MoveWindow(Globals.hEdit,
982  rc.left,
983  rc.top,
984  rc.right - rc.left,
985  rc.bottom - rc.top,
986  TRUE);
987  }
988 
989  /* Set the status bar for multiple-text output */
991 
992  /* Update content with current row/column text */
994 
995  /* Update line endings and encoding on the status bar */
998 }
999 
1001 {
1002  DWORD dwStyle;
1003  int iSize;
1004  LPTSTR pTemp = NULL;
1005  BOOL bModified = FALSE;
1006 
1007  iSize = 0;
1008 
1009  /* If the edit control already exists, try to save its content */
1010  if (Globals.hEdit != NULL)
1011  {
1012  /* number of chars currently written into the editor. */
1013  iSize = GetWindowTextLength(Globals.hEdit);
1014  if (iSize)
1015  {
1016  /* Allocates temporary buffer. */
1017  pTemp = HeapAlloc(GetProcessHeap(), 0, (iSize + 1) * sizeof(TCHAR));
1018  if (!pTemp)
1019  {
1020  ShowLastError();
1021  return;
1022  }
1023 
1024  /* Recover the text into the control. */
1025  GetWindowText(Globals.hEdit, pTemp, iSize + 1);
1026 
1027  if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
1028  bModified = TRUE;
1029  }
1030 
1031  /* Restore original window procedure */
1033 
1034  /* Destroy the edit control */
1035  DestroyWindow(Globals.hEdit);
1036  }
1037 
1038  /* Update wrap status into the main menu and recover style flags */
1039  if (Globals.bWrapLongLines)
1040  {
1041  dwStyle = EDIT_STYLE_WRAP;
1043  } else {
1044  dwStyle = EDIT_STYLE;
1046  }
1047 
1048  /* Update previous changes */
1050 
1051  /* Create the new edit control */
1053  EDIT_CLASS,
1054  NULL,
1055  dwStyle,
1056  CW_USEDEFAULT,
1057  CW_USEDEFAULT,
1058  CW_USEDEFAULT,
1059  CW_USEDEFAULT,
1060  Globals.hMainWnd,
1061  NULL,
1063  NULL);
1064 
1065  if (Globals.hEdit == NULL)
1066  {
1067  if (pTemp)
1068  {
1069  HeapFree(GetProcessHeap(), 0, pTemp);
1070  }
1071 
1072  ShowLastError();
1073  return;
1074  }
1075 
1076  SendMessage(Globals.hEdit, WM_SETFONT, (WPARAM)Globals.hFont, FALSE);
1077  SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0);
1078 
1079  /* If some text was previously saved, restore it. */
1080  if (iSize != 0)
1081  {
1082  SetWindowText(Globals.hEdit, pTemp);
1083  HeapFree(GetProcessHeap(), 0, pTemp);
1084 
1085  if (bModified)
1086  SendMessage(Globals.hEdit, EM_SETMODIFY, TRUE, 0);
1087  }
1088 
1089  /* Sub-class a new window callback for row/column detection. */
1090  Globals.EditProc = (WNDPROC)SetWindowLongPtr(Globals.hEdit,
1091  GWLP_WNDPROC,
1093 
1094  /* Create/update status bar */
1096 
1097  /* Finally shows new edit control and set focus into it. */
1098  ShowWindow(Globals.hEdit, SW_SHOW);
1099  SetFocus(Globals.hEdit);
1100 }
1101 
1103 {
1104  Globals.bWrapLongLines = !Globals.bWrapLongLines;
1105 
1106  if (Globals.bWrapLongLines)
1107  {
1109  }
1110  else
1111  {
1113  }
1114 
1116 }
1117 
1119 {
1120  CHOOSEFONT cf;
1121  LOGFONT lf = Globals.lfFont;
1122 
1123  ZeroMemory( &cf, sizeof(cf) );
1124  cf.lStructSize = sizeof(cf);
1125  cf.hwndOwner = Globals.hMainWnd;
1126  cf.lpLogFont = &lf;
1128 
1129  if (ChooseFont(&cf))
1130  {
1131  HFONT currfont = Globals.hFont;
1132 
1133  Globals.hFont = CreateFontIndirect(&lf);
1134  Globals.lfFont = lf;
1136  if (currfont != NULL)
1137  DeleteObject(currfont);
1138  }
1139 }
1140 
1142 
1144 {
1145  if (Globals.hFindReplaceDlg != NULL)
1146  {
1147  SetFocus(Globals.hFindReplaceDlg);
1148  return;
1149  }
1150 
1151  ZeroMemory(&Globals.find, sizeof(Globals.find));
1152  Globals.find.lStructSize = sizeof(Globals.find);
1153  Globals.find.hwndOwner = Globals.hMainWnd;
1155  Globals.find.lpstrFindWhat = Globals.szFindText;
1156  Globals.find.wFindWhatLen = ARRAY_SIZE(Globals.szFindText);
1157  Globals.find.lpstrReplaceWith = Globals.szReplaceText;
1158  Globals.find.wReplaceWithLen = ARRAY_SIZE(Globals.szReplaceText);
1159  Globals.find.Flags = FR_DOWN;
1160 
1161  /* We only need to create the modal FindReplace dialog which will */
1162  /* notify us of incoming events using hMainWnd Window Messages */
1163 
1164  Globals.hFindReplaceDlg = pfnProc(&Globals.find);
1165  assert(Globals.hFindReplaceDlg != NULL);
1166 }
1167 
1169 {
1171 }
1172 
1174 {
1175  if (Globals.find.lpstrFindWhat != NULL)
1177  else
1178  DIALOG_Search();
1179 }
1180 
1182 {
1184 }
1185 
1186 static INT_PTR
1187 CALLBACK
1189 {
1190  BOOL bResult = FALSE;
1191  HWND hTextBox;
1192  TCHAR szText[32];
1193 
1194  switch(uMsg) {
1195  case WM_INITDIALOG:
1196  hTextBox = GetDlgItem(hwndDialog, ID_LINENUMBER);
1197  _sntprintf(szText, ARRAY_SIZE(szText), _T("%Id"), lParam);
1198  SetWindowText(hTextBox, szText);
1199  break;
1200  case WM_COMMAND:
1201  if (HIWORD(wParam) == BN_CLICKED)
1202  {
1203  if (LOWORD(wParam) == IDOK)
1204  {
1205  hTextBox = GetDlgItem(hwndDialog, ID_LINENUMBER);
1206  GetWindowText(hTextBox, szText, ARRAY_SIZE(szText));
1207  EndDialog(hwndDialog, _ttoi(szText));
1208  bResult = TRUE;
1209  }
1210  else if (LOWORD(wParam) == IDCANCEL)
1211  {
1212  EndDialog(hwndDialog, 0);
1213  bResult = TRUE;
1214  }
1215  }
1216  break;
1217  }
1218 
1219  return bResult;
1220 }
1221 
1223 {
1224  INT_PTR nLine;
1225  LPTSTR pszText;
1226  int nLength, i;
1227  DWORD dwStart, dwEnd;
1228 
1230  pszText = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(*pszText));
1231  if (!pszText)
1232  return;
1233 
1234  /* Retrieve current text */
1235  GetWindowText(Globals.hEdit, pszText, nLength + 1);
1236  SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwStart, (LPARAM) &dwEnd);
1237 
1238  nLine = 1;
1239  for (i = 0; (i < (int) dwStart) && pszText[i]; i++)
1240  {
1241  if (pszText[i] == '\n')
1242  nLine++;
1243  }
1244 
1247  Globals.hMainWnd,
1249  nLine);
1250 
1251  if (nLine >= 1)
1252  {
1253  for (i = 0; pszText[i] && (nLine > 1) && (i < nLength - 1); i++)
1254  {
1255  if (pszText[i] == '\n')
1256  nLine--;
1257  }
1258  SendMessage(Globals.hEdit, EM_SETSEL, i, i);
1259  SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
1260  }
1261  HeapFree(GetProcessHeap(), 0, pszText);
1262 }
1263 
1265 {
1266  int line, col;
1267  TCHAR buff[MAX_PATH];
1268  DWORD dwStart, dwSize;
1269 
1270  SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize);
1271  line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0);
1272  col = dwStart - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);
1273 
1274  _stprintf(buff, Globals.szStatusBarLineCol, line + 1, col + 1);
1276 }
1277 
1279 {
1280  Globals.bShowStatusBar = !Globals.bShowStatusBar;
1281 
1283 }
1284 
1286 {
1288 }
1289 
1291 {
1292  TCHAR szNotepad[MAX_STRING_LEN];
1293  TCHAR szNotepadAuthors[MAX_STRING_LEN];
1294 
1296 
1297  LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad));
1298  LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, ARRAY_SIZE(szNotepadAuthors));
1299 
1300  ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors, notepadIcon);
1301  DeleteObject(notepadIcon);
1302 }
1303 
1304 /***********************************************************************
1305  *
1306  * DIALOG_FilePageSetup
1307  */
1309 {
1311 
1312  ZeroMemory(&page, sizeof(page));
1313  page.lStructSize = sizeof(page);
1314  page.hwndOwner = Globals.hMainWnd;
1316  page.hInstance = Globals.hInstance;
1317  page.rtMargin = Globals.lMargins;
1318  page.hDevMode = Globals.hDevMode;
1319  page.hDevNames = Globals.hDevNames;
1320  page.lpPageSetupTemplateName = MAKEINTRESOURCE(DIALOG_PAGESETUP);
1321  page.lpfnPageSetupHook = DIALOG_PAGESETUP_Hook;
1322 
1323  PageSetupDlg(&page);
1324 
1325  Globals.hDevMode = page.hDevMode;
1326  Globals.hDevNames = page.hDevNames;
1327  Globals.lMargins = page.rtMargin;
1328 }
1329 
1330 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1331  *
1332  * DIALOG_PAGESETUP_Hook
1333  */
1334 
1336 {
1337  switch (msg)
1338  {
1339  case WM_COMMAND:
1340  if (HIWORD(wParam) == BN_CLICKED)
1341  {
1342  switch (LOWORD(wParam))
1343  {
1344  case IDOK:
1345  /* save user input and close dialog */
1346  GetDlgItemText(hDlg, 0x141, Globals.szHeader, ARRAY_SIZE(Globals.szHeader));
1347  GetDlgItemText(hDlg, 0x143, Globals.szFooter, ARRAY_SIZE(Globals.szFooter));
1348  return FALSE;
1349 
1350  case IDCANCEL:
1351  /* discard user input and close dialog */
1352  return FALSE;
1353 
1354  case IDHELP:
1355  {
1356  /* FIXME: Bring this to work */
1357  static const TCHAR sorry[] = _T("Sorry, no help available");
1358  static const TCHAR help[] = _T("Help");
1360  return TRUE;
1361  }
1362 
1363  default:
1364  break;
1365  }
1366  }
1367  break;
1368 
1369  case WM_INITDIALOG:
1370  /* fetch last user input prior to display dialog */
1371  SetDlgItemText(hDlg, 0x141, Globals.szHeader);
1372  SetDlgItemText(hDlg, 0x143, Globals.szFooter);
1373  break;
1374  }
1375 
1376  return FALSE;
1377 }
#define MB_ICONMASK
Definition: winuser.h:813
#define EM_LIMITTEXT
Definition: winuser.h:1990
static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:1335
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
static IClassFactory * cf
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:87
#define OFN_EXPLORER
Definition: commdlg.h:104
VOID DIALOG_Search(VOID)
Definition: dialog.c:1168
#define STRING_LINE_COLUMN
Definition: notepad_res.h:101
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define STRING_LF
Definition: notepad_res.h:98
#define HORZRES
Definition: wingdi.h:716
#define max(a, b)
Definition: svc.c:63
#define LOGPIXELSX
Definition: wingdi.h:718
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
static HICON
Definition: imagelist.c:84
#define MF_DISABLED
Definition: winuser.h:130
#define PD_NOSELECTION
Definition: commdlg.h:149
static UINT_PTR CALLBACK DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:541
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define IDOK
Definition: winuser.h:824
#define CloseHandle
Definition: compat.h:598
WORD nMaxPage
Definition: commdlg.h:474
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define VARIABLE_PITCH
Definition: wingdi.h:445
static const TCHAR empty_str[]
Definition: dialog.c:32
#define STRING_ANSI
Definition: notepad_res.h:91
#define MF_BYCOMMAND
Definition: winuser.h:202
VOID DoOpenFile(LPCTSTR szFileName)
Definition: dialog.c:420
#define PSD_ENABLEPAGESETUPTEMPLATE
Definition: commdlg.h:184
#define PageSetupDlg
Definition: commdlg.h:667
#define WM_CUT
Definition: winuser.h:1851
#define error(str)
Definition: mkdosfs.c:1605
#define IDYES
Definition: winuser.h:829
VOID DIALOG_FileExit(VOID)
Definition: dialog.c:867
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HWND hwndOwner
Definition: commdlg.h:330
#define STRING_UTF8
Definition: notepad_res.h:94
Definition: mk_font.cpp:20
static BOOL DoSaveFile(VOID)
Definition: dialog.c:333
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define SW_HIDE
Definition: winuser.h:762
static const D3D_BLOB_PART parts[]
Definition: blob.c:76
#define PSD_MARGINS
Definition: commdlg.h:173
VOID DIALOG_EditSelectAll(VOID)
Definition: dialog.c:897
#define LOCALE_USER_DEFAULT
static VOID DIALOG_StatusBarUpdateLineEndings(VOID)
Definition: dialog.c:146
static HDC
Definition: imagelist.c:92
#define CALLBACK
Definition: compat.h:35
_In_ DWORD nLength
Definition: wincon.h:473
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
HANDLE HWND
Definition: compat.h:19
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define WM_PASTE
Definition: winuser.h:1853
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define assert(x)
Definition: debug.h:53
#define StringCchCopyN
Definition: strsafe.h:227
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define ZeroMemory
Definition: winbase.h:1667
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LPCSTR lpstrDefExt
Definition: commdlg.h:345
#define MAX_STRING_LEN
Definition: precomp.h:36
HWND WINAPI SetFocus(_In_opt_ HWND)
BYTE lfCharSet
Definition: dimm.idl:50
WORD nCopies
Definition: commdlg.h:475
static void AlertFileNotFound(LPCTSTR szFileName)
Definition: dialog.c:188
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, int iEoln)
Definition: text.c:370
LPCSTR lpTemplateName
Definition: commdlg.h:348
LONG left
Definition: windef.h:306
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
VOID DIALOG_EditCopy(VOID)
Definition: dialog.c:882
int32_t INT_PTR
Definition: typedefs.h:64
#define STRING_UTF8_BOM
Definition: notepad_res.h:95
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:144
BOOL HasFileExtension(LPCTSTR szFilename)
Definition: dialog.c:231
#define GetTextMetrics
Definition: wingdi.h:4474
#define CMD_GOTO
Definition: notepad_res.h:56
#define WM_CLEAR
Definition: winuser.h:1854
LONG right
Definition: windef.h:308
#define NO_ERROR
Definition: dderror.h:5
static UINT EolnToStrId[]
Definition: dialog.c:42
BOOL WINAPI DestroyWindow(_In_ HWND)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define STRSAFE_E_INSUFFICIENT_BUFFER
Definition: strsafe.h:103
#define PROOF_QUALITY
Definition: wingdi.h:438
#define SetWindowLongPtr
Definition: treelist.c:70
#define GetOpenFileName
Definition: commdlg.h:665
#define CB_GETCURSEL
Definition: winuser.h:1933
WPARAM wParam
Definition: combotst.c:138
CHAR * LPTSTR
Definition: xmlstorage.h:192
int WINAPI EndPage(_In_ HDC)
#define FILE_SHARE_READ
Definition: compat.h:136
static RECT GetPrintingRect(HDC hdc, RECT margins)
Definition: dialog.c:309
BYTE lfOutPrecision
Definition: dimm.idl:51
#define ID_ENCODING
Definition: notepad_res.h:28
WORD nMinPage
Definition: commdlg.h:473
#define GetWindowText
Definition: winuser.h:5788
#define STRING_NOTEPAD_AUTHORS
Definition: notepad_res.h:107
DWORD nMaxFile
Definition: commdlg.h:337
#define IDHELP
Definition: resource_2.h:8
#define EM_GETSEL
Definition: winuser.h:1987
int WINAPI StartPage(_In_ HDC)
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define ChooseFont
Definition: commdlg.h:662
#define PHYSICALHEIGHT
Definition: wingdi.h:736
#define SBPART_CURPOS
Definition: dialog.c:37
#define GetSaveFileName
Definition: commdlg.h:666
BOOL ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, int *piEoln)
Definition: text.c:96
#define PrintDlg
Definition: commdlg.h:668
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define CMD_STATUSBAR
Definition: notepad_res.h:61
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347
#define STRING_NOTEPAD
Definition: notepad_res.h:75
#define FALSE
Definition: types.h:117
#define DIALOG_PAGESETUP
Definition: notepad_res.h:25
#define WM_COPY
Definition: winuser.h:1852
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:220
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define CreateStatusWindow
Definition: commctrl.h:1933
#define CF_SCREENFONTS
Definition: commdlg.h:59
LONG lfHeight
Definition: dimm.idl:42
#define GENERIC_WRITE
Definition: nt_native.h:90
#define ShellExecute
Definition: shellapi.h:691
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
BOOL DoCloseFile(VOID)
Definition: dialog.c:388
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
#define STRING_NOTSAVED
Definition: notepad_res.h:85
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:416
VOID DIALOG_EditDelete(VOID)
Definition: dialog.c:892
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
#define CreateWindowEx
Definition: winuser.h:5745
#define CW_USEDEFAULT
Definition: winuser.h:225
#define CB_ADDSTRING
Definition: winuser.h:1926
VOID DIALOG_FilePageSetup(void)
Definition: dialog.c:1308
LONG lfWeight
Definition: dimm.idl:46
WORD nFromPage
Definition: commdlg.h:471
#define MB_ICONQUESTION
Definition: winuser.h:783
VOID DoCreateStatusBar(VOID)
Definition: dialog.c:918
#define MB_YESNOCANCEL
Definition: winuser.h:812
int GetSelectionText(HWND hWnd, LPTSTR lpString, int nMaxCount)
Definition: dialog.c:251
LONG cx
Definition: windef.h:334
#define PD_SELECTION
Definition: commdlg.h:147
LONG_PTR LPARAM
Definition: windef.h:208
Definition: parser.c:48
#define PD_RETURNDC
Definition: commdlg.h:155
Definition: module.h:566
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
HINSTANCE hInstance
Definition: commdlg.h:331
#define STRING_UNICODE_BE
Definition: notepad_res.h:93
BYTE lfPitchAndFamily
Definition: dimm.idl:54
static const TCHAR szDefaultExt[]
Definition: dialog.c:33
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define FindFirstFile
Definition: winbase.h:3643
#define SW_SHOW
Definition: winuser.h:769
VOID DIALOG_SelectFont(VOID)
Definition: dialog.c:1118
VOID DIALOG_GoTo(VOID)
Definition: dialog.c:1222
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:420
VOID DIALOG_SearchNext(VOID)
Definition: dialog.c:1173
#define STRING_CRLF
Definition: notepad_res.h:97
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:1000
#define STRING_PRINTERROR
Definition: notepad_res.h:102
#define PostMessage
Definition: winuser.h:5822
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
r l[0]
Definition: byte_order.h:167
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:180
#define CCS_BOTTOM
Definition: commctrl.h:2244
#define MF_CHECKED
Definition: winuser.h:132
#define DIALOG_ENCODING
Definition: notepad_res.h:27
char TCHAR
Definition: xmlstorage.h:189
#define DIALOG_GOTO
Definition: notepad_res.h:30
#define _T(x)
Definition: vfdio.h:22
DWORD fwType
Definition: wingdi.h:1680
VOID ShowLastError(VOID)
Definition: dialog.c:59
GLsizeiptr size
Definition: glext.h:5919
LPCSTR lpszOutput
Definition: wingdi.h:1678
#define GetDlgItemText
Definition: winuser.h:5775
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define PHYSICALOFFSETY
Definition: wingdi.h:738
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STRING_UNTITLED
Definition: notepad_res.h:79
#define SBARS_SIZEGRIP
Definition: commctrl.h:1923
#define WM_SIZE
Definition: winuser.h:1601
LONG HRESULT
Definition: typedefs.h:79
#define EDIT_CLASS
Definition: main.h:32
VOID DIALOG_EditPaste(VOID)
Definition: dialog.c:887
VOID DIALOG_FileOpen(VOID)
Definition: dialog.c:496
#define CDN_FILEOK
Definition: commdlg.h:38
#define StringCbPrintf
Definition: strsafe.h:544
#define MF_ENABLED
Definition: winuser.h:128
#define WM_CLOSE
Definition: winuser.h:1611
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
#define MAX_PATH
Definition: compat.h:34
DWORD lStructSize
Definition: commdlg.h:329
#define EM_GETMODIFY
Definition: winuser.h:1984
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:1264
#define WINAPI
Definition: msvc.h:6
static UINT EncToStrId[]
Definition: dialog.c:49
#define EM_SETSEL
Definition: winuser.h:2008
#define ReplaceText
Definition: commdlg.h:669
VOID DIALOG_FilePrint(VOID)
Definition: dialog.c:652
unsigned short WORD
Definition: ntddk_ex.h:93
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define BN_CLICKED
Definition: winuser.h:1915
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL hDevMode
Definition: commdlg.h:467
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define ShellAbout
Definition: shellapi.h:690
#define SB_SETTEXTW
Definition: commctrl.h:1942
#define GetModuleFileName
Definition: winbase.h:3692
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define OPEN_ALWAYS
Definition: disk.h:70
#define SetDlgItemText
Definition: winuser.h:5839
#define ID_EOLN
Definition: notepad_res.h:29
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define PD_PAGENUMS
Definition: commdlg.h:148
#define FormatMessage
Definition: winbase.h:3656
#define DialogBoxParam
Definition: winuser.h:5754
LPCSTR lpszDatatype
Definition: wingdi.h:1679
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define EM_UNDO
Definition: winuser.h:2011
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:167
#define SBPART_EOLN
Definition: dialog.c:38
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1975
#define StringCchCopy
Definition: strsafe.h:139
HDC hdc
Definition: main.c:9
#define PD_USEDEVMODECOPIES
Definition: commdlg.h:165
static const TCHAR txt_files[]
Definition: dialog.c:34
#define SB_SETTEXT
Definition: commctrl.h:1949
HWND(WINAPI * FINDPROC)(LPFINDREPLACE lpfr)
Definition: dialog.c:1141
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define MB_ICONERROR
Definition: winuser.h:781
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
uint32_t entry
Definition: isohybrid.c:63
#define _sntprintf
Definition: xmlstorage.h:201
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define SBPART_ENCODING
Definition: dialog.c:39
GLdouble s
Definition: gl.h:2039
#define MessageBox
Definition: winuser.h:5812
#define HELP_INDEX
Definition: winuser.h:2400
#define GENERIC_READ
Definition: compat.h:135
#define CB_SETCURSEL
Definition: winuser.h:1951
#define EM_SETMODIFY
Definition: winuser.h:2003
Definition: time.h:68
#define FF_ROMAN
Definition: wingdi.h:450
static VOID DIALOG_StatusBarUpdateEncoding(VOID)
Definition: dialog.c:155
#define WM_COMMAND
Definition: winuser.h:1730
Definition: inflate.c:139
IN PCTCH line
Definition: pager.h:36
int cbSize
Definition: wingdi.h:1676
#define MF_UNCHECKED
Definition: winuser.h:204
_In_ HANDLE hFile
Definition: mswsock.h:90
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
static RECT margins
Definition: print.c:55
#define GWLP_WNDPROC
Definition: treelist.c:66
BYTE lfQuality
Definition: dimm.idl:53
HWND hwndOwner
Definition: commdlg.h:466
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2896
#define PHYSICALOFFSETX
Definition: wingdi.h:737
#define GetTimeFormat
Definition: winnls.h:1189
#define _stprintf
Definition: utility.h:124
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
ENCODING
Definition: more.c:491
#define PHYSICALWIDTH
Definition: wingdi.h:735
#define S_OK
Definition: intsafe.h:52
#define CREATE_ALWAYS
Definition: disk.h:72
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define lstrlen
Definition: winbase.h:3737
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:310
#define FW_BOLD
Definition: wingdi.h:378
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2083
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
HINSTANCE hInstance
Definition: commdlg.h:476
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID DIALOG_EditUndo(VOID)
Definition: dialog.c:872
BOOL WINAPI DeleteDC(_In_ HDC)
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define EM_LINEFROMCHAR
Definition: winuser.h:1991
LPSTR lpstrFile
Definition: commdlg.h:336
LPCWSTR szPath
Definition: env.c:37
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:1143
#define GetDateFormat
Definition: winnls.h:1184
#define ARRAY_SIZE(a)
Definition: main.h:24
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
LPCSTR lpszDocName
Definition: wingdi.h:1677
BYTE lfClipPrecision
Definition: dimm.idl:52
HGLOBAL hDevNames
Definition: commdlg.h:468
#define FindText
Definition: commdlg.h:663
#define IDI_NPICON
Definition: notepad_res.h:32
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define DATE_LONGDATE
Definition: winnls.h:197
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define STRING_ERROR
Definition: notepad_res.h:76
#define SetWindowText
Definition: winuser.h:5847
LPCSTR lpstrFilter
Definition: commdlg.h:332
#define ID_LINENUMBER
Definition: notepad_res.h:31
#define CreateFontIndirect
Definition: wingdi.h:4444
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
#define VERTRES
Definition: wingdi.h:717
#define STRING_NOTFOUND
Definition: notepad_res.h:87
#define SB_SETPARTS
Definition: commctrl.h:1954
static const TCHAR helpfile[]
Definition: dialog.c:31
VOID DIALOG_Replace(VOID)
Definition: dialog.c:1181
#define WM_SETFONT
Definition: winuser.h:1640
VOID DIALOG_EditCut(VOID)
Definition: dialog.c:877
#define FR_DOWN
Definition: commdlg.h:127
DWORD lStructSize
Definition: commdlg.h:465
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define msg(x)
Definition: auth_time.c:54
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:34
BOOL DIALOG_FileSaveAs(VOID)
Definition: dialog.c:600
WORD nToPage
Definition: commdlg.h:472
#define STRING_UNICODE
Definition: notepad_res.h:92
#define MM_TEXT
Definition: wingdi.h:873
#define GetTextExtentPoint32
Definition: wingdi.h:4472
#define SendMessage
Definition: winuser.h:5833
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
#define EM_LINEINDEX
Definition: winuser.h:1992
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem)
Definition: dialog.c:2181
#define HIWORD(l)
Definition: typedefs.h:247
#define EDIT_STYLE_WRAP
Definition: main.h:28
#define TextOut
Definition: wingdi.h:4483
#define EDIT_STYLE
Definition: main.h:30
#define GetWindowTextLength
Definition: winuser.h:5789
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
VOID DIALOG_HelpAboutNotepad(VOID)
Definition: dialog.c:1290
LONG bottom
Definition: windef.h:309
#define LOGPIXELSY
Definition: wingdi.h:719
VOID DIALOG_FileNew(VOID)
Definition: dialog.c:478
DWORD Flags
Definition: commdlg.h:470
#define StartDoc
Definition: wingdi.h:4482
VOID DIALOG_EditWrap(VOID)
Definition: dialog.c:1102
#define LoadIcon
Definition: winuser.h:5803
#define IDNO
Definition: winuser.h:830
static void AlertPrintError(void)
Definition: dialog.c:204
int GetSelectionTextLength(HWND hWnd)
Definition: dialog.c:241
#define MF_GRAYED
Definition: winuser.h:129
#define ANSI_CHARSET
Definition: wingdi.h:383
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define IDCANCEL
Definition: winuser.h:825
#define CF_NOVERTFONTS
Definition: commdlg.h:86
#define PSD_ENABLEPAGESETUPHOOK
Definition: commdlg.h:183
LONG_PTR LRESULT
Definition: windef.h:209
VOID DIALOG_HelpContents(VOID)
Definition: dialog.c:1285
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:902
HINSTANCE hInstance
Definition: precomp.h:43
VOID DIALOG_ViewStatusBar(VOID)
Definition: dialog.c:1278
#define WS_VISIBLE
Definition: pedump.c:620
#define CMD_STATUSBAR_WND_ID
Definition: notepad_res.h:62
HDC hDC
Definition: commdlg.h:469
int help
Definition: sort.c:20
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
_In_ int nMaxCount
Definition: winuser.h:4867
#define LOWORD(l)
Definition: pedump.c:82
static unsigned char buff[32768]
Definition: fatten.c:17
#define STRING_CR
Definition: notepad_res.h:99
VOID DIALOG_FileNewWindow(VOID)
Definition: dialog.c:489
static int AlertFileNotSaved(LPCTSTR szFileName)
Definition: dialog.c:193
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define LoadString
Definition: winuser.h:5809
#define log(outFile, fmt,...)
Definition: util.h:15
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66
#define WM_NOTIFY
Definition: richedit.h:61
#define EM_REPLACESEL
Definition: winuser.h:1996
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:525
#define EM_SCROLLCARET
Definition: richedit.h:81
DOCINFOA DOCINFO
Definition: wingdi.h:4414
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
VOID DIALOG_StatusBarAlignParts(VOID)
Definition: dialog.c:128
int WINAPI EndDoc(_In_ HDC)
DWORD Flags
Definition: commdlg.h:342
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
#define WinHelp
Definition: winuser.h:5854
static INT_PTR CALLBACK DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:1188