ReactOS  0.4.15-dev-1203-g0e5a4d5
dialog.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

VOID DIALOG_FileNew (VOID)
 
VOID DIALOG_FileOpen (VOID)
 
BOOL DIALOG_FileSave (VOID)
 
BOOL DIALOG_FileSaveAs (VOID)
 
VOID DIALOG_FilePrint (VOID)
 
VOID DIALOG_FilePageSetup (VOID)
 
VOID DIALOG_FileExit (VOID)
 
VOID DIALOG_EditUndo (VOID)
 
VOID DIALOG_EditCut (VOID)
 
VOID DIALOG_EditCopy (VOID)
 
VOID DIALOG_EditPaste (VOID)
 
VOID DIALOG_EditDelete (VOID)
 
VOID DIALOG_EditSelectAll (VOID)
 
VOID DIALOG_EditTimeDate (VOID)
 
VOID DIALOG_EditWrap (VOID)
 
VOID DIALOG_Search (VOID)
 
VOID DIALOG_SearchNext (VOID)
 
VOID DIALOG_Replace (VOID)
 
VOID DIALOG_GoTo (VOID)
 
VOID DIALOG_SelectFont (VOID)
 
VOID DIALOG_ViewStatusBar (VOID)
 
VOID DIALOG_StatusBarUpdateCaretPos (VOID)
 
VOID DIALOG_HelpContents (VOID)
 
VOID DIALOG_HelpSearch (VOID)
 
VOID DIALOG_HelpLicense (VOID)
 
VOID DIALOG_HelpNoWarranty (VOID)
 
VOID DIALOG_HelpAboutNotepad (VOID)
 
VOID DIALOG_TimeDate (VOID)
 
int DIALOG_StringMsgBox (HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
 
INT_PTR CALLBACK AboutDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
 
VOID ShowLastError (VOID)
 
BOOL FileExists (LPCTSTR szFilename)
 
BOOL HasFileExtension (LPCTSTR szFilename)
 
BOOL DoCloseFile (VOID)
 
VOID DoOpenFile (LPCTSTR szFileName)
 
VOID DoCreateStatusBar (VOID)
 
VOID DoCreateEditWindow (VOID)
 

Function Documentation

◆ AboutDialogProc()

INT_PTR CALLBACK AboutDialogProc ( HWND  hDlg,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 4 of file about.c.

8 {
9  HWND hLicenseEditWnd;
10  HICON hIcon = NULL;
11  TCHAR strLicense[700];
12 
13  switch (message)
14  {
15  case WM_INITDIALOG:
16 
19  IMAGE_ICON,
20  16,
21  16,
22  0);
23 
24  SendMessage(hDlg,
25  WM_SETICON,
26  ICON_SMALL,
27  (LPARAM)hIcon);
28 
29  hLicenseEditWnd = GetDlgItem(hDlg,
31 
34  strLicense,
35  sizeof(strLicense) / sizeof(TCHAR));
36 
37  SetWindowText(hLicenseEditWnd,
38  strLicense);
39  return TRUE;
40 
41  case WM_COMMAND:
42  if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
43  {
45  EndDialog(hDlg,
46  LOWORD(wParam));
47  return TRUE;
48  }
49 
50  break;
51  }
52 
53  return FALSE;
54 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
Definition: tftpd.h:59
static HICON
Definition: imagelist.c:84
#define IDOK
Definition: winuser.h:824
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
#define TRUE
Definition: types.h:120
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define ICON_SMALL
Definition: tnclass.cpp:48
HINSTANCE hInstance
Definition: charmap.c:20
#define FALSE
Definition: types.h:117
#define IDI_IMAGESOFTICON
Definition: resource.h:13
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
char TCHAR
Definition: xmlstorage.h:189
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define WM_COMMAND
Definition: winuser.h:1722
#define IDS_LICENSE
Definition: resource.h:28
HICON hIcon
Definition: msconfig.c:44
#define SetWindowText
Definition: winuser.h:5832
#define SendMessage
Definition: winuser.h:5818
#define LoadImage
Definition: winuser.h:5790
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
#define LOWORD(l)
Definition: pedump.c:82
#define LoadString
Definition: winuser.h:5794
#define IDC_LICENSE_EDIT
Definition: resource.h:20

◆ DIALOG_EditCopy()

VOID DIALOG_EditCopy ( VOID  )

Definition at line 796 of file dialog.c.

797 {
798  SendMessage(Globals.hEdit, WM_COPY, 0, 0);
799 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define WM_COPY
Definition: winuser.h:1844
#define SendMessage
Definition: winuser.h:5818

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditCut()

VOID DIALOG_EditCut ( VOID  )

Definition at line 791 of file dialog.c.

792 {
793  SendMessage(Globals.hEdit, WM_CUT, 0, 0);
794 }
#define WM_CUT
Definition: winuser.h:1843
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SendMessage
Definition: winuser.h:5818

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditDelete()

VOID DIALOG_EditDelete ( VOID  )

Definition at line 806 of file dialog.c.

807 {
808  SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
809 }
#define WM_CLEAR
Definition: winuser.h:1846
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SendMessage
Definition: winuser.h:5818

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditPaste()

VOID DIALOG_EditPaste ( VOID  )

Definition at line 801 of file dialog.c.

802 {
803  SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
804 }
#define WM_PASTE
Definition: winuser.h:1845
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SendMessage
Definition: winuser.h:5818

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditSelectAll()

VOID DIALOG_EditSelectAll ( VOID  )

Definition at line 811 of file dialog.c.

812 {
813  SendMessage(Globals.hEdit, EM_SETSEL, 0, (LPARAM)-1);
814 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG_PTR LPARAM
Definition: windef.h:208
#define EM_SETSEL
Definition: winuser.h:2000
#define SendMessage
Definition: winuser.h:5818

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditTimeDate()

VOID DIALOG_EditTimeDate ( VOID  )

Definition at line 816 of file dialog.c.

817 {
818  SYSTEMTIME st;
820  TCHAR szText[MAX_STRING_LEN * 2 + 2];
821 
822  GetLocalTime(&st);
823 
826  _tcscat(szText, _T(" "));
830 }
#define TRUE
Definition: types.h:120
#define LOCALE_USER_DEFAULT
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define MAX_STRING_LEN
Definition: precomp.h:36
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
static const WCHAR szText[]
Definition: dialog.c:139
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
static const WCHAR szDate[]
Definition: http.c:100
#define GetTimeFormat
Definition: winnls.h:1186
#define GetDateFormat
Definition: winnls.h:1181
#define DATE_LONGDATE
Definition: winnls.h:194
#define SendMessage
Definition: winuser.h:5818
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
#define EM_REPLACESEL
Definition: winuser.h:1988

Referenced by DoOpenFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_EditUndo()

VOID DIALOG_EditUndo ( VOID  )

Definition at line 786 of file dialog.c.

787 {
788  SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
789 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define EM_UNDO
Definition: winuser.h:2003
#define SendMessage
Definition: winuser.h:5818

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditWrap()

VOID DIALOG_EditWrap ( VOID  )

Definition at line 1012 of file dialog.c.

1013 {
1014  Globals.bWrapLongLines = !Globals.bWrapLongLines;
1015 
1016  if (Globals.bWrapLongLines)
1017  {
1019  }
1020  else
1021  {
1023  }
1024 
1026 }
#define MF_DISABLED
Definition: winuser.h:130
#define MF_BYCOMMAND
Definition: winuser.h:202
#define CMD_GOTO
Definition: notepad_res.h:55
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:910
#define MF_ENABLED
Definition: winuser.h:128
#define MF_GRAYED
Definition: winuser.h:129

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileExit()

VOID DIALOG_FileExit ( VOID  )

Definition at line 781 of file dialog.c.

782 {
784 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define PostMessage
Definition: winuser.h:5807
r l[0]
Definition: byte_order.h:167
#define WM_CLOSE
Definition: winuser.h:1603

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileNew()

VOID DIALOG_FileNew ( VOID  )

Definition at line 407 of file dialog.c.

408 {
409  /* Close any files and prompt to save changes */
410  if (DoCloseFile()) {
412  SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
413  SetFocus(Globals.hEdit);
415  }
416 }
static const TCHAR empty_str[]
Definition: dialog.c:32
HWND WINAPI SetFocus(_In_opt_ HWND)
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
BOOL DoCloseFile(VOID)
Definition: dialog.c:322
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1967
#define SetWindowText
Definition: winuser.h:5832
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:34
#define SendMessage
Definition: winuser.h:5818

Referenced by _tWinMain(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileOpen()

VOID DIALOG_FileOpen ( VOID  )

Definition at line 418 of file dialog.c.

419 {
420  OPENFILENAME openfilename;
422 
423  ZeroMemory(&openfilename, sizeof(openfilename));
424 
425  if (Globals.szFileName[0] == 0)
427  else
428  _tcscpy(szPath, Globals.szFileName);
429 
430  openfilename.lStructSize = sizeof(openfilename);
431  openfilename.hwndOwner = Globals.hMainWnd;
432  openfilename.hInstance = Globals.hInstance;
433  openfilename.lpstrFilter = Globals.szFilter;
434  openfilename.lpstrFile = szPath;
435  openfilename.nMaxFile = ARRAY_SIZE(szPath);
437  openfilename.lpstrDefExt = szDefaultExt;
438 
439  if (GetOpenFileName(&openfilename)) {
440  if (FileExists(openfilename.lpstrFile))
441  DoOpenFile(openfilename.lpstrFile);
442  else
443  AlertFileNotFound(openfilename.lpstrFile);
444  }
445 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
VOID DoOpenFile(LPCTSTR szFileName)
Definition: dialog.c:354
HWND hwndOwner
Definition: commdlg.h:330
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1648
LPCSTR lpstrDefExt
Definition: commdlg.h:345
static void AlertFileNotFound(LPCTSTR szFileName)
Definition: dialog.c:122
#define GetOpenFileName
Definition: commdlg.h:665
DWORD nMaxFile
Definition: commdlg.h:337
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:154
HINSTANCE hInstance
Definition: commdlg.h:331
static const TCHAR szDefaultExt[]
Definition: dialog.c:33
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:34
DWORD lStructSize
Definition: commdlg.h:329
static const TCHAR txt_files[]
Definition: dialog.c:34
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
LPSTR lpstrFile
Definition: commdlg.h:336
LPCWSTR szPath
Definition: env.c:35
#define ARRAY_SIZE(a)
Definition: main.h:24
LPCSTR lpstrFilter
Definition: commdlg.h:332
HINSTANCE hInstance
Definition: precomp.h:43
DWORD Flags
Definition: commdlg.h:342

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FilePageSetup()

VOID DIALOG_FilePageSetup ( VOID  )

Definition at line 1218 of file dialog.c.

1219 {
1221 
1222  ZeroMemory(&page, sizeof(page));
1223  page.lStructSize = sizeof(page);
1224  page.hwndOwner = Globals.hMainWnd;
1226  page.hInstance = Globals.hInstance;
1227  page.rtMargin = Globals.lMargins;
1228  page.hDevMode = Globals.hDevMode;
1229  page.hDevNames = Globals.hDevNames;
1230  page.lpPageSetupTemplateName = MAKEINTRESOURCE(DIALOG_PAGESETUP);
1231  page.lpfnPageSetupHook = DIALOG_PAGESETUP_Hook;
1232 
1233  PageSetupDlg(&page);
1234 
1235  Globals.hDevMode = page.hDevMode;
1236  Globals.hDevNames = page.hDevNames;
1237  Globals.lMargins = page.rtMargin;
1238 }
static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:1245
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define PSD_ENABLEPAGESETUPTEMPLATE
Definition: commdlg.h:184
#define PageSetupDlg
Definition: commdlg.h:667
#define PSD_MARGINS
Definition: commdlg.h:173
#define ZeroMemory
Definition: winbase.h:1648
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define DIALOG_PAGESETUP
Definition: notepad_res.h:25
Definition: module.h:566
#define PSD_ENABLEPAGESETUPHOOK
Definition: commdlg.h:183
HINSTANCE hInstance
Definition: precomp.h:43

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FilePrint()

VOID DIALOG_FilePrint ( VOID  )

Definition at line 566 of file dialog.c.

567 {
568  DOCINFO di;
569  TEXTMETRIC tm;
570  PRINTDLG printer;
571  SIZE szMetric;
572  int border;
573  int xLeft, yTop, pagecount, dopage, copycount;
574  unsigned int i;
575  LOGFONT hdrFont;
576  HFONT font, old_font=0;
577  DWORD size;
578  LPTSTR pTemp;
579  static const TCHAR times_new_roman[] = _T("Times New Roman");
580  RECT rcPrintRect;
581 
582  /* Get a small font and print some header info on each page */
583  ZeroMemory(&hdrFont, sizeof(hdrFont));
584  hdrFont.lfHeight = 100;
585  hdrFont.lfWeight = FW_BOLD;
586  hdrFont.lfCharSet = ANSI_CHARSET;
589  hdrFont.lfQuality = PROOF_QUALITY;
591  _tcscpy(hdrFont.lfFaceName, times_new_roman);
592 
593  font = CreateFontIndirect(&hdrFont);
594 
595  /* Get Current Settings */
596  ZeroMemory(&printer, sizeof(printer));
597  printer.lStructSize = sizeof(printer);
598  printer.hwndOwner = Globals.hMainWnd;
599  printer.hInstance = Globals.hInstance;
600 
601  /* Set some default flags */
602  printer.Flags = PD_RETURNDC | PD_SELECTION;
603 
604  /* Disable the selection radio button if there is no text selected */
605  if (!GetSelectionTextLength(Globals.hEdit))
606  {
607  printer.Flags = printer.Flags | PD_NOSELECTION;
608  }
609 
610  printer.nFromPage = 0;
611  printer.nMinPage = 1;
612  /* we really need to calculate number of pages to set nMaxPage and nToPage */
613  printer.nToPage = (WORD)-1;
614  printer.nMaxPage = (WORD)-1;
615 
616  /* Let commdlg manage copy settings */
617  printer.nCopies = (WORD)PD_USEDEVMODECOPIES;
618 
619  printer.hDevMode = Globals.hDevMode;
620  printer.hDevNames = Globals.hDevNames;
621 
622  if (!PrintDlg(&printer))
623  {
625  return;
626  }
627 
628  Globals.hDevMode = printer.hDevMode;
629  Globals.hDevNames = printer.hDevNames;
630 
631  assert(printer.hDC != 0);
632 
633  /* initialize DOCINFO */
634  di.cbSize = sizeof(DOCINFO);
635  di.lpszDocName = Globals.szFileTitle;
636  di.lpszOutput = NULL;
637  di.lpszDatatype = NULL;
638  di.fwType = 0;
639 
640  if (StartDoc(printer.hDC, &di) <= 0)
641  {
643  return;
644  }
645 
646 
647  /* Get the file text */
648  if (printer.Flags & PD_SELECTION)
649  {
650  size = GetSelectionTextLength(Globals.hEdit) + 1;
651  }
652  else
653  {
654  size = GetWindowTextLength(Globals.hEdit) + 1;
655  }
656 
657  pTemp = HeapAlloc(GetProcessHeap(), 0, size * sizeof(TCHAR));
658  if (!pTemp)
659  {
660  EndDoc(printer.hDC);
662  ShowLastError();
663  return;
664  }
665 
666  if (printer.Flags & PD_SELECTION)
667  {
668  size = GetSelectionText(Globals.hEdit, pTemp, size);
669  }
670  else
671  {
672  size = GetWindowText(Globals.hEdit, pTemp, size);
673  }
674 
675  /* Get the current printing area */
676  rcPrintRect = GetPrintingRect(printer.hDC, Globals.lMargins);
677 
678  /* Ensure that each logical unit maps to one pixel */
679  SetMapMode(printer.hDC, MM_TEXT);
680 
681  /* Needed to get the correct height of a text line */
682  GetTextMetrics(printer.hDC, &tm);
683 
684  border = 15;
685  for (copycount=1; copycount <= printer.nCopies; copycount++) {
686  i = 0;
687  pagecount = 1;
688  do {
689  /* Don't start a page if none of the conditions below are true */
690  dopage = 0;
691 
692  /* The user wants to print the current selection */
693  if (printer.Flags & PD_SELECTION)
694  {
695  dopage = 1;
696  }
697 
698  /* The user wants to print the entire document */
699  if (!(printer.Flags & PD_PAGENUMS) && !(printer.Flags & PD_SELECTION))
700  {
701  dopage = 1;
702  }
703 
704  /* The user wants to print a specified range of pages */
705  if ((pagecount >= printer.nFromPage && pagecount <= printer.nToPage))
706  {
707  dopage = 1;
708  }
709 
710  old_font = SelectObject(printer.hDC, font);
711 
712  if (dopage) {
713  if (StartPage(printer.hDC) <= 0) {
714  SelectObject(printer.hDC, old_font);
715  EndDoc(printer.hDC);
716  DeleteDC(printer.hDC);
717  HeapFree(GetProcessHeap(), 0, pTemp);
719  AlertPrintError();
720  return;
721  }
722 
723  SetViewportOrgEx(printer.hDC, rcPrintRect.left, rcPrintRect.top, NULL);
724 
725  /* Write a rectangle and header at the top of each page */
726  Rectangle(printer.hDC, border, border, rcPrintRect.right - border, border + tm.tmHeight * 2);
727  /* I don't know what's up with this TextOut command. This comes out
728  kind of mangled.
729  */
730  TextOut(printer.hDC,
731  border * 2,
732  border + tm.tmHeight / 2,
733  Globals.szFileTitle,
734  lstrlen(Globals.szFileTitle));
735  }
736 
737  /* The starting point for the main text */
738  xLeft = 0;
739  yTop = border + tm.tmHeight * 4;
740 
741  SelectObject(printer.hDC, old_font);
742 
743  /* Since outputting strings is giving me problems, output the main
744  * text one character at a time. */
745  do {
746  if (pTemp[i] == '\n') {
747  xLeft = 0;
748  yTop += tm.tmHeight;
749  }
750  else if (pTemp[i] != '\r') {
751  if (dopage)
752  TextOut(printer.hDC, xLeft, yTop, &pTemp[i], 1);
753 
754  /* We need to get the width for each individual char, since a proportional font may be used */
755  GetTextExtentPoint32(printer.hDC, &pTemp[i], 1, &szMetric);
756  xLeft += szMetric.cx;
757 
758  /* Insert a line break if the current line does not fit into the printing area */
759  if (xLeft > rcPrintRect.right)
760  {
761  xLeft = 0;
762  yTop = yTop + tm.tmHeight;
763  }
764  }
765  } while (i++ < size && yTop < rcPrintRect.bottom);
766 
767  if (dopage)
768  EndPage(printer.hDC);
769  pagecount++;
770  } while (i < size);
771  }
772 
773  if (old_font != 0)
774  SelectObject(printer.hDC, old_font);
775  EndDoc(printer.hDC);
776  DeleteDC(printer.hDC);
777  HeapFree(GetProcessHeap(), 0, pTemp);
779 }
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define PD_NOSELECTION
Definition: commdlg.h:149
WORD nMaxPage
Definition: commdlg.h:474
#define VARIABLE_PITCH
Definition: wingdi.h:444
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
Definition: mk_font.cpp:20
LONG top
Definition: windef.h:307
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define assert(x)
Definition: debug.h:53
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BYTE lfCharSet
Definition: dimm.idl:50
WORD nCopies
Definition: commdlg.h:475
LONG left
Definition: windef.h:306
#define GetTextMetrics
Definition: wingdi.h:4473
LONG right
Definition: windef.h:308
#define PROOF_QUALITY
Definition: wingdi.h:437
CHAR * LPTSTR
Definition: xmlstorage.h:192
int WINAPI EndPage(_In_ HDC)
static RECT GetPrintingRect(HDC hdc, RECT margins)
Definition: dialog.c:243
BYTE lfOutPrecision
Definition: dimm.idl:51
WORD nMinPage
Definition: commdlg.h:473
#define GetWindowText
Definition: winuser.h:5773
int WINAPI StartPage(_In_ HDC)
#define PrintDlg
Definition: commdlg.h:668
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
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
int WINAPI SetMapMode(_In_ HDC, _In_ int)
LONG lfHeight
Definition: dimm.idl:42
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:425
LONG lfWeight
Definition: dimm.idl:46
WORD nFromPage
Definition: commdlg.h:471
smooth NULL
Definition: ftsmooth.c:416
int GetSelectionText(HWND hWnd, LPTSTR lpString, int nMaxCount)
Definition: dialog.c:185
LONG cx
Definition: windef.h:334
#define PD_SELECTION
Definition: commdlg.h:147
#define PD_RETURNDC
Definition: commdlg.h:155
BYTE lfPitchAndFamily
Definition: dimm.idl:54
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
DWORD fwType
Definition: wingdi.h:1679
VOID ShowLastError(VOID)
Definition: dialog.c:38
GLsizeiptr size
Definition: glext.h:5919
LPCSTR lpszOutput
Definition: wingdi.h:1677
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLint GLint GLsizei GLsizei GLsizei GLint border
Definition: gl.h:1546
unsigned short WORD
Definition: ntddk_ex.h:93
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:414
unsigned long DWORD
Definition: ntddk_ex.h:95
HGLOBAL hDevMode
Definition: commdlg.h:467
#define PD_PAGENUMS
Definition: commdlg.h:148
LPCSTR lpszDatatype
Definition: wingdi.h:1678
#define PD_USEDEVMODECOPIES
Definition: commdlg.h:165
Definition: time.h:76
#define FF_ROMAN
Definition: wingdi.h:449
int cbSize
Definition: wingdi.h:1675
BYTE lfQuality
Definition: dimm.idl:53
HWND hwndOwner
Definition: commdlg.h:466
#define lstrlen
Definition: winbase.h:3716
#define FW_BOLD
Definition: wingdi.h:377
HINSTANCE hInstance
Definition: commdlg.h:476
BOOL WINAPI DeleteDC(_In_ HDC)
LPCSTR lpszDocName
Definition: wingdi.h:1676
BYTE lfClipPrecision
Definition: dimm.idl:52
HGLOBAL hDevNames
Definition: commdlg.h:468
#define CreateFontIndirect
Definition: wingdi.h:4443
DWORD lStructSize
Definition: commdlg.h:465
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
WORD nToPage
Definition: commdlg.h:472
#define MM_TEXT
Definition: wingdi.h:872
#define GetTextExtentPoint32
Definition: wingdi.h:4471
#define TextOut
Definition: wingdi.h:4482
#define GetWindowTextLength
Definition: winuser.h:5774
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
LONG bottom
Definition: windef.h:309
DWORD Flags
Definition: commdlg.h:470
#define StartDoc
Definition: wingdi.h:4481
static void AlertPrintError(void)
Definition: dialog.c:138
int GetSelectionTextLength(HWND hWnd)
Definition: dialog.c:175
#define ANSI_CHARSET
Definition: wingdi.h:382
HINSTANCE hInstance
Definition: precomp.h:43
HDC hDC
Definition: commdlg.h:469
#define HeapFree(x, y, z)
Definition: compat.h:594
DOCINFOA DOCINFO
Definition: wingdi.h:4413
int WINAPI EndDoc(_In_ HDC)

Referenced by HandleCommandLine(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileSave()

BOOL DIALOG_FileSave ( VOID  )

Definition at line 447 of file dialog.c.

448 {
449  if (Globals.szFileName[0] == 0)
450  {
451  return DIALOG_FileSaveAs();
452  }
453  else if (DoSaveFile())
454  {
456  return TRUE;
457  }
458  return FALSE;
459 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:66
static BOOL DoSaveFile(VOID)
Definition: dialog.c:267
#define TRUE
Definition: types.h:120
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FALSE
Definition: types.h:117
BOOL DIALOG_FileSaveAs(VOID)
Definition: dialog.c:519

Referenced by DoCloseFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileSaveAs()

BOOL DIALOG_FileSaveAs ( VOID  )

Definition at line 519 of file dialog.c.

520 {
521  OPENFILENAME saveas;
523 
524  ZeroMemory(&saveas, sizeof(saveas));
525 
526  if (Globals.szFileName[0] == 0)
528  else
529  _tcscpy(szPath, Globals.szFileName);
530 
531  saveas.lStructSize = sizeof(OPENFILENAME);
532  saveas.hwndOwner = Globals.hMainWnd;
533  saveas.hInstance = Globals.hInstance;
534  saveas.lpstrFilter = Globals.szFilter;
535  saveas.lpstrFile = szPath;
536  saveas.nMaxFile = ARRAY_SIZE(szPath);
539  saveas.lpstrDefExt = szDefaultExt;
542 
543  if (GetSaveFileName(&saveas))
544  {
545  /* HACK: Because in ROS, Save-As boxes don't check the validity
546  * of file names and thus, here, szPath can be invalid !! We only
547  * see its validity when we call DoSaveFile()... */
549  if (DoSaveFile())
550  {
552  return TRUE;
553  }
554  else
555  {
556  SetFileName(_T(""));
557  return FALSE;
558  }
559  }
560  else
561  {
562  return FALSE;
563  }
564 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:66
#define OFN_EXPLORER
Definition: commdlg.h:104
#define MAKEINTRESOURCE
Definition: winuser.h:591
static UINT_PTR CALLBACK DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:463
HWND hwndOwner
Definition: commdlg.h:330
static BOOL DoSaveFile(VOID)
Definition: dialog.c:267
#define TRUE
Definition: types.h:120
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1648
LPCSTR lpstrDefExt
Definition: commdlg.h:345
LPCSTR lpTemplateName
Definition: commdlg.h:348
DWORD nMaxFile
Definition: commdlg.h:337
#define GetSaveFileName
Definition: commdlg.h:666
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347
#define FALSE
Definition: types.h:117
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
HINSTANCE hInstance
Definition: commdlg.h:331
static const TCHAR szDefaultExt[]
Definition: dialog.c:33
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:179
#define DIALOG_ENCODING
Definition: notepad_res.h:27
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define MAX_PATH
Definition: compat.h:34
DWORD lStructSize
Definition: commdlg.h:329
static const TCHAR txt_files[]
Definition: dialog.c:34
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
LPSTR lpstrFile
Definition: commdlg.h:336
LPCWSTR szPath
Definition: env.c:35
#define ARRAY_SIZE(a)
Definition: main.h:24
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
LPCSTR lpstrFilter
Definition: commdlg.h:332
HINSTANCE hInstance
Definition: precomp.h:43
DWORD Flags
Definition: commdlg.h:342

Referenced by DIALOG_FileSave(), and NOTEPAD_MenuCommand().

◆ DIALOG_GoTo()

VOID DIALOG_GoTo ( VOID  )

Definition at line 1132 of file dialog.c.

1133 {
1134  INT_PTR nLine;
1135  LPTSTR pszText;
1136  int nLength, i;
1137  DWORD dwStart, dwEnd;
1138 
1140  pszText = (LPTSTR) HeapAlloc(GetProcessHeap(), 0, (nLength + 1) * sizeof(*pszText));
1141  if (!pszText)
1142  return;
1143 
1144  /* Retrieve current text */
1145  GetWindowText(Globals.hEdit, pszText, nLength + 1);
1146  SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwStart, (LPARAM) &dwEnd);
1147 
1148  nLine = 1;
1149  for (i = 0; (i < (int) dwStart) && pszText[i]; i++)
1150  {
1151  if (pszText[i] == '\n')
1152  nLine++;
1153  }
1154 
1157  Globals.hMainWnd,
1159  nLine);
1160 
1161  if (nLine >= 1)
1162  {
1163  for (i = 0; pszText[i] && (nLine > 1) && (i < nLength - 1); i++)
1164  {
1165  if (pszText[i] == '\n')
1166  nLine--;
1167  }
1168  SendMessage(Globals.hEdit, EM_SETSEL, i, i);
1169  SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
1170  }
1171  HeapFree(GetProcessHeap(), 0, pszText);
1172 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
_In_ DWORD nLength
Definition: wincon.h:476
UINT_PTR WPARAM
Definition: windef.h:207
int32_t INT_PTR
Definition: typedefs.h:64
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define GetWindowText
Definition: winuser.h:5773
#define EM_GETSEL
Definition: winuser.h:1979
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
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
LONG_PTR LPARAM
Definition: windef.h:208
#define DIALOG_GOTO
Definition: notepad_res.h:30
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define EM_SETSEL
Definition: winuser.h:2000
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DialogBoxParam
Definition: winuser.h:5739
#define SendMessage
Definition: winuser.h:5818
#define GetWindowTextLength
Definition: winuser.h:5774
HINSTANCE hInstance
Definition: precomp.h:43
#define HeapFree(x, y, z)
Definition: compat.h:594
#define EM_SCROLLCARET
Definition: richedit.h:81
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static INT_PTR CALLBACK DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:1098

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_HelpAboutNotepad()

VOID DIALOG_HelpAboutNotepad ( VOID  )

Definition at line 1200 of file dialog.c.

1201 {
1202  TCHAR szNotepad[MAX_STRING_LEN];
1203  TCHAR szNotepadAuthors[MAX_STRING_LEN];
1204 
1206 
1207  LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad));
1208  LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, ARRAY_SIZE(szNotepadAuthors));
1209 
1210  ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors, notepadIcon);
1211  DeleteObject(notepadIcon);
1212 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
static HICON
Definition: imagelist.c:84
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define MAX_STRING_LEN
Definition: precomp.h:36
#define STRING_NOTEPAD_AUTHORS
Definition: notepad_res.h:104
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define STRING_NOTEPAD
Definition: notepad_res.h:74
char TCHAR
Definition: xmlstorage.h:189
#define ShellAbout
Definition: shellapi.h:690
#define ARRAY_SIZE(a)
Definition: main.h:24
#define IDI_NPICON
Definition: notepad_res.h:32
#define LoadIcon
Definition: winuser.h:5788
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5794

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_HelpContents()

VOID DIALOG_HelpContents ( VOID  )

Definition at line 1195 of file dialog.c.

1196 {
1198 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define HELP_INDEX
Definition: winuser.h:2385
static const TCHAR helpfile[]
Definition: dialog.c:31
#define WinHelp
Definition: winuser.h:5839

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_HelpLicense()

VOID DIALOG_HelpLicense ( VOID  )

◆ DIALOG_HelpNoWarranty()

VOID DIALOG_HelpNoWarranty ( VOID  )

◆ DIALOG_HelpSearch()

VOID DIALOG_HelpSearch ( VOID  )

◆ DIALOG_Replace()

VOID DIALOG_Replace ( VOID  )

Definition at line 1091 of file dialog.c.

1092 {
1094 }
#define ReplaceText
Definition: commdlg.h:669
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:1053

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_Search()

VOID DIALOG_Search ( VOID  )

Definition at line 1078 of file dialog.c.

1079 {
1081 }
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:1053
#define FindText
Definition: commdlg.h:663

Referenced by DIALOG_SearchNext(), and NOTEPAD_MenuCommand().

◆ DIALOG_SearchNext()

VOID DIALOG_SearchNext ( VOID  )

Definition at line 1083 of file dialog.c.

1084 {
1085  if (Globals.find.lpstrFindWhat != NULL)
1087  else
1088  DIALOG_Search();
1089 }
VOID DIALOG_Search(VOID)
Definition: dialog.c:1078
#define TRUE
Definition: types.h:120
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:143
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_SelectFont()

VOID DIALOG_SelectFont ( VOID  )

Definition at line 1028 of file dialog.c.

1029 {
1030  CHOOSEFONT cf;
1031  LOGFONT lf = Globals.lfFont;
1032 
1033  ZeroMemory( &cf, sizeof(cf) );
1034  cf.lStructSize = sizeof(cf);
1035  cf.hwndOwner = Globals.hMainWnd;
1036  cf.lpLogFont = &lf;
1038 
1039  if (ChooseFont(&cf))
1040  {
1041  HFONT currfont = Globals.hFont;
1042 
1043  Globals.hFont = CreateFontIndirect(&lf);
1044  Globals.lfFont = lf;
1046  if (currfont != NULL)
1047  DeleteObject(currfont);
1048  }
1049 }
static IClassFactory * cf
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1648
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
UINT_PTR WPARAM
Definition: windef.h:207
#define ChooseFont
Definition: commdlg.h:662
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define CF_SCREENFONTS
Definition: commdlg.h:59
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define CreateFontIndirect
Definition: wingdi.h:4443
#define WM_SETFONT
Definition: winuser.h:1632
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define SendMessage
Definition: winuser.h:5818
#define CF_NOVERTFONTS
Definition: commdlg.h:86
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_StatusBarUpdateCaretPos()

VOID DIALOG_StatusBarUpdateCaretPos ( VOID  )

Definition at line 1174 of file dialog.c.

1175 {
1176  int line, col;
1177  TCHAR buff[MAX_PATH];
1178  DWORD dwStart, dwSize;
1179 
1180  SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize);
1181  line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0);
1182  col = dwStart - SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);
1183 
1184  _stprintf(buff, Globals.szStatusBarLineCol, line + 1, col + 1);
1186 }
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_GETSEL
Definition: winuser.h:1979
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SB_SIMPLEID
Definition: precomp.h:15
LONG_PTR LPARAM
Definition: windef.h:208
Definition: parser.c:48
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
char line[200]
Definition: main.c:97
#define SB_SETTEXT
Definition: commctrl.h:1945
#define _stprintf
Definition: utility.h:124
#define EM_LINEFROMCHAR
Definition: winuser.h:1983
#define SendMessage
Definition: winuser.h:5818
#define EM_LINEINDEX
Definition: winuser.h:1984
static unsigned char buff[32768]
Definition: fatten.c:17
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by DoCreateStatusBar(), EDIT_WndProc(), and NOTEPAD_WndProc().

◆ DIALOG_StringMsgBox()

int DIALOG_StringMsgBox ( HWND  hParent,
int  formatId,
LPCTSTR  szString,
DWORD  dwFlags 
)

Definition at line 101 of file dialog.c.

102 {
103  TCHAR szMessage[MAX_STRING_LEN];
104  TCHAR szResource[MAX_STRING_LEN];
105 
106  /* Load and format szMessage */
107  LoadString(Globals.hInstance, formatId, szResource, ARRAY_SIZE(szResource));
108  _sntprintf(szMessage, ARRAY_SIZE(szMessage), szResource, szString);
109 
110  /* Load szCaption */
112  LoadString(Globals.hInstance, STRING_ERROR, szResource, ARRAY_SIZE(szResource));
113  else
114  LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, ARRAY_SIZE(szResource));
115 
116  /* Display Modal Dialog */
117  // if (hParent == NULL)
118  // hParent = Globals.hMainWnd;
119  return MessageBox(hParent, szMessage, szResource, dwFlags);
120 }
#define MB_ICONMASK
Definition: winuser.h:813
#define MAX_STRING_LEN
Definition: precomp.h:36
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define STRING_NOTEPAD
Definition: notepad_res.h:74
char TCHAR
Definition: xmlstorage.h:189
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
const DOCKBAR PVOID HWND hParent
Definition: tooldock.h:22
#define _sntprintf
Definition: xmlstorage.h:201
#define MessageBox
Definition: winuser.h:5797
#define ARRAY_SIZE(a)
Definition: main.h:24
#define STRING_ERROR
Definition: notepad_res.h:75
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5794

Referenced by AlertFileDoesNotExist(), AlertFileNotFound(), AlertFileNotSaved(), and AlertPrintError().

◆ DIALOG_TimeDate()

VOID DIALOG_TimeDate ( VOID  )

◆ DIALOG_ViewStatusBar()

VOID DIALOG_ViewStatusBar ( VOID  )

Definition at line 1188 of file dialog.c.

1189 {
1190  Globals.bShowStatusBar = !Globals.bShowStatusBar;
1191 
1193 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
VOID DoCreateStatusBar(VOID)
Definition: dialog.c:832

Referenced by _tWinMain(), and NOTEPAD_MenuCommand().

◆ DoCloseFile()

BOOL DoCloseFile ( VOID  )

Returns: TRUE - User agreed to close (both save/don't save) FALSE - User cancelled close by selecting "Cancel"

Definition at line 322 of file dialog.c.

323 {
324  int nResult;
325 
326  if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
327  {
328  /* prompt user to save changes */
329  nResult = AlertFileNotSaved(Globals.szFileName);
330  switch (nResult)
331  {
332  case IDYES:
333  if(!DIALOG_FileSave())
334  return FALSE;
335  break;
336 
337  case IDNO:
338  break;
339 
340  case IDCANCEL:
341  return FALSE;
342 
343  default:
344  return FALSE;
345  }
346  }
347 
350 
351  return TRUE;
352 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:66
static const TCHAR empty_str[]
Definition: dialog.c:32
#define IDYES
Definition: winuser.h:829
#define TRUE
Definition: types.h:120
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FALSE
Definition: types.h:117
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:179
#define EM_GETMODIFY
Definition: winuser.h:1976
#define SendMessage
Definition: winuser.h:5818
#define IDNO
Definition: winuser.h:830
#define IDCANCEL
Definition: winuser.h:825
static int AlertFileNotSaved(LPCTSTR szFileName)
Definition: dialog.c:127
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:447

Referenced by DIALOG_FileNew(), DoOpenFile(), and NOTEPAD_WndProc().

◆ DoCreateEditWindow()

VOID DoCreateEditWindow ( VOID  )

Definition at line 910 of file dialog.c.

911 {
912  DWORD dwStyle;
913  int iSize;
914  LPTSTR pTemp = NULL;
915  BOOL bModified = FALSE;
916 
917  iSize = 0;
918 
919  /* If the edit control already exists, try to save its content */
920  if (Globals.hEdit != NULL)
921  {
922  /* number of chars currently written into the editor. */
923  iSize = GetWindowTextLength(Globals.hEdit);
924  if (iSize)
925  {
926  /* Allocates temporary buffer. */
927  pTemp = HeapAlloc(GetProcessHeap(), 0, (iSize + 1) * sizeof(TCHAR));
928  if (!pTemp)
929  {
930  ShowLastError();
931  return;
932  }
933 
934  /* Recover the text into the control. */
935  GetWindowText(Globals.hEdit, pTemp, iSize + 1);
936 
937  if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
938  bModified = TRUE;
939  }
940 
941  /* Restore original window procedure */
943 
944  /* Destroy the edit control */
945  DestroyWindow(Globals.hEdit);
946  }
947 
948  /* Update wrap status into the main menu and recover style flags */
949  if (Globals.bWrapLongLines)
950  {
951  dwStyle = EDIT_STYLE_WRAP;
953  } else {
954  dwStyle = EDIT_STYLE;
956  }
957 
958  /* Update previous changes */
960 
961  /* Create the new edit control */
963  EDIT_CLASS,
964  NULL,
965  dwStyle,
971  NULL,
973  NULL);
974 
975  if (Globals.hEdit == NULL)
976  {
977  if (pTemp)
978  {
979  HeapFree(GetProcessHeap(), 0, pTemp);
980  }
981 
982  ShowLastError();
983  return;
984  }
985 
987  SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0);
988 
989  /* If some text was previously saved, restore it. */
990  if (iSize != 0)
991  {
992  SetWindowText(Globals.hEdit, pTemp);
993  HeapFree(GetProcessHeap(), 0, pTemp);
994 
995  if (bModified)
996  SendMessage(Globals.hEdit, EM_SETMODIFY, TRUE, 0);
997  }
998 
999  /* Sub-class a new window callback for row/column detection. */
1000  Globals.EditProc = (WNDPROC)SetWindowLongPtr(Globals.hEdit,
1001  GWLP_WNDPROC,
1003 
1004  /* Create/update status bar */
1006 
1007  /* Finally shows new edit control and set focus into it. */
1008  ShowWindow(Globals.hEdit, SW_SHOW);
1009  SetFocus(Globals.hEdit);
1010 }
#define EM_LIMITTEXT
Definition: winuser.h:1982
#define MF_DISABLED
Definition: winuser.h:130
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define TRUE
Definition: types.h:120
HWND WINAPI SetFocus(_In_opt_ HWND)
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define SetWindowLongPtr
Definition: treelist.c:70
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define GetWindowText
Definition: winuser.h:5773
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define CMD_STATUSBAR
Definition: notepad_res.h:60
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CreateWindowEx
Definition: winuser.h:5730
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
VOID DoCreateStatusBar(VOID)
Definition: dialog.c:832
#define SW_SHOW
Definition: winuser.h:769
char TCHAR
Definition: xmlstorage.h:189
VOID ShowLastError(VOID)
Definition: dialog.c:38
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define EDIT_CLASS
Definition: main.h:32
#define MF_ENABLED
Definition: winuser.h:128
#define EM_GETMODIFY
Definition: winuser.h:1976
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EM_SETMODIFY
Definition: winuser.h:1995
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:309
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SetWindowText
Definition: winuser.h:5832
#define WM_SETFONT
Definition: winuser.h:1632
#define SendMessage
Definition: winuser.h:5818
#define EDIT_STYLE_WRAP
Definition: main.h:28
#define EDIT_STYLE
Definition: main.h:30
#define GetWindowTextLength
Definition: winuser.h:5774
#define MF_GRAYED
Definition: winuser.h:129
HINSTANCE hInstance
Definition: precomp.h:43
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by _tWinMain(), and DIALOG_EditWrap().

◆ DoCreateStatusBar()

VOID DoCreateStatusBar ( VOID  )

Definition at line 832 of file dialog.c.

833 {
834  RECT rc;
835  RECT rcstatus;
836  BOOL bStatusBarVisible;
837 
838  /* Check if status bar object already exists. */
839  if (Globals.hStatusBar == NULL)
840  {
841  /* Try to create the status bar */
843  NULL,
846 
847  if (Globals.hStatusBar == NULL)
848  {
849  ShowLastError();
850  return;
851  }
852 
853  /* Load the string for formatting column/row text output */
854  LoadString(Globals.hInstance, STRING_LINE_COLUMN, Globals.szStatusBarLineCol, MAX_PATH - 1);
855 
856  /* Set the status bar for single-text output */
857  SendMessage(Globals.hStatusBar, SB_SIMPLE, (WPARAM)TRUE, (LPARAM)0);
858  }
859 
860  /* Set status bar visiblity according to the settings. */
861  if ((Globals.bWrapLongLines != FALSE) || (Globals.bShowStatusBar == FALSE))
862  {
863  bStatusBarVisible = FALSE;
864  ShowWindow(Globals.hStatusBar, SW_HIDE);
865  }
866  else
867  {
868  bStatusBarVisible = TRUE;
869  ShowWindow(Globals.hStatusBar, SW_SHOW);
870  SendMessage(Globals.hStatusBar, WM_SIZE, 0, 0);
871  }
872 
873  /* Set check state in show status bar item. */
874  if (bStatusBarVisible)
875  {
877  }
878  else
879  {
881  }
882 
883  /* Update menu mar with the previous changes */
885 
886  /* Sefety test is edit control exists */
887  if (Globals.hEdit != NULL)
888  {
889  /* Retrieve the sizes of the controls */
891  GetClientRect(Globals.hStatusBar, &rcstatus);
892 
893  /* If status bar is currently visible, update dimensions of edit control */
894  if (bStatusBarVisible)
895  rc.bottom -= (rcstatus.bottom - rcstatus.top);
896 
897  /* Resize edit control to right size. */
898  MoveWindow(Globals.hEdit,
899  rc.left,
900  rc.top,
901  rc.right - rc.left,
902  rc.bottom - rc.top,
903  TRUE);
904  }
905 
906  /* Update content with current row/column text */
908 }
#define STRING_LINE_COLUMN
Definition: notepad_res.h:99
BOOL WINAPI DrawMenuBar(_In_ HWND)
#define MF_BYCOMMAND
Definition: winuser.h:202
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
LONG top
Definition: windef.h:307
UINT_PTR WPARAM
Definition: windef.h:207
#define WS_CHILD
Definition: pedump.c:617
LONG left
Definition: windef.h:306
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:308
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define CMD_STATUSBAR
Definition: notepad_res.h:60
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CreateStatusWindow
Definition: commctrl.h:1929
#define SB_SIMPLE
Definition: commctrl.h:1954
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define SW_SHOW
Definition: winuser.h:769
#define MF_CHECKED
Definition: winuser.h:132
VOID ShowLastError(VOID)
Definition: dialog.c:38
#define WM_SIZE
Definition: winuser.h:1593
#define MAX_PATH
Definition: compat.h:34
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:1174
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_UNCHECKED
Definition: winuser.h:204
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SendMessage
Definition: winuser.h:5818
LONG bottom
Definition: windef.h:309
HINSTANCE hInstance
Definition: precomp.h:43
#define WS_VISIBLE
Definition: pedump.c:620
#define CMD_STATUSBAR_WND_ID
Definition: notepad_res.h:61
#define WS_EX_STATICEDGE
Definition: winuser.h:403
#define LoadString
Definition: winuser.h:5794

Referenced by DIALOG_ViewStatusBar(), and DoCreateEditWindow().

◆ DoOpenFile()

VOID DoOpenFile ( LPCTSTR  szFileName)

Definition at line 354 of file dialog.c.

355 {
356  static const TCHAR dotlog[] = _T(".LOG");
357  HANDLE hFile;
358  LPTSTR pszText = NULL;
359  DWORD dwTextLen;
360  TCHAR log[5];
361 
362  /* Close any files and prompt to save changes */
363  if (!DoCloseFile())
364  return;
365 
369  {
370  ShowLastError();
371  goto done;
372  }
373 
374  if (!ReadText(hFile, (LPWSTR *)&pszText, &dwTextLen, &Globals.encFile, &Globals.iEoln))
375  {
376  ShowLastError();
377  goto done;
378  }
379  SetWindowText(Globals.hEdit, pszText);
380 
382  SendMessage(Globals.hEdit, EM_EMPTYUNDOBUFFER, 0, 0);
383  SetFocus(Globals.hEdit);
384 
385  /* If the file starts with .LOG, add a time/date at the end and set cursor after
386  * See http://support.microsoft.com/?kbid=260563
387  */
388  if (GetWindowText(Globals.hEdit, log, ARRAY_SIZE(log)) && !_tcscmp(log, dotlog))
389  {
390  static const TCHAR lf[] = _T("\r\n");
395  }
396 
397  SetFileName(szFileName);
400 done:
403  if (pszText)
404  HeapFree(GetProcessHeap(), 0, pszText);
405 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:66
#define CloseHandle
Definition: compat.h:598
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
HWND WINAPI SetFocus(_In_opt_ HWND)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define FILE_SHARE_READ
Definition: compat.h:136
#define GetWindowText
Definition: winuser.h:5773
BOOL ReadText(HANDLE hFile, LPWSTR *ppszText, DWORD *pdwTextLen, ENCODING *pencFile, int *piEoln)
Definition: text.c:96
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FALSE
Definition: types.h:117
BOOL DoCloseFile(VOID)
Definition: dialog.c:322
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:179
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
VOID ShowLastError(VOID)
Definition: dialog.c:38
#define GetProcessHeap()
Definition: compat.h:595
#define EM_SETSEL
Definition: winuser.h:2000
unsigned long DWORD
Definition: ntddk_ex.h:95
#define OPEN_ALWAYS
Definition: disk.h:70
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1967
#define GENERIC_READ
Definition: compat.h:135
#define EM_SETMODIFY
Definition: winuser.h:1995
_In_ HANDLE hFile
Definition: mswsock.h:90
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define ARRAY_SIZE(a)
Definition: main.h:24
#define SetWindowText
Definition: winuser.h:5832
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:34
#define SendMessage
Definition: winuser.h:5818
#define GetWindowTextLength
Definition: winuser.h:5774
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:816
#define HeapFree(x, y, z)
Definition: compat.h:594
#define log(outFile, fmt,...)
Definition: util.h:15
#define EM_REPLACESEL
Definition: winuser.h:1988

Referenced by DIALOG_FileOpen().

◆ FileExists()

BOOL FileExists ( LPCTSTR  szFilename)

Returns: TRUE - if file exists FALSE - if file does not exist

Definition at line 154 of file dialog.c.

155 {
157  HANDLE hFile;
158 
159  hFile = FindFirstFile(szFilename, &entry);
160  FindClose(hFile);
161 
162  return (hFile != INVALID_HANDLE_VALUE);
163 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define FindFirstFile
Definition: winbase.h:3622
uint32_t entry
Definition: isohybrid.c:63
_In_ HANDLE hFile
Definition: mswsock.h:90
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by DIALOG_FileOpen(), and HandleCommandLine().

◆ HasFileExtension()

BOOL HasFileExtension ( LPCTSTR  szFilename)

Definition at line 165 of file dialog.c.

166 {
167  LPCTSTR s;
168 
169  s = _tcsrchr(szFilename, _T('\\'));
170  if (s)
171  szFilename = s;
172  return _tcsrchr(szFilename, _T('.')) != NULL;
173 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
GLdouble s
Definition: gl.h:2039
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4

Referenced by HandleCommandLine().

◆ ShowLastError()

VOID ShowLastError ( VOID  )

Definition at line 38 of file dialog.c.

39 {
41  if (error != NO_ERROR)
42  {
43  LPTSTR lpMsgBuf = NULL;
45 
47 
49  NULL,
50  error,
51  0,
52  (LPTSTR) &lpMsgBuf,
53  0,
54  NULL);
55 
56  MessageBox(NULL, lpMsgBuf, szTitle, MB_OK | MB_ICONERROR);
57  LocalFree(lpMsgBuf);
58  }
59 }
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define MAX_STRING_LEN
Definition: precomp.h:36
#define NO_ERROR
Definition: dderror.h:5
CHAR * LPTSTR
Definition: xmlstorage.h:192
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
char TCHAR
Definition: xmlstorage.h:189
unsigned long DWORD
Definition: ntddk_ex.h:95
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define FormatMessage
Definition: winbase.h:3635
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5797
#define ARRAY_SIZE(a)
Definition: main.h:24
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define STRING_ERROR
Definition: notepad_res.h:75
#define MB_OK
Definition: winuser.h:784
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5794

Referenced by _tWinMain(), DIALOG_FilePrint(), DoCreateEditWindow(), DoCreateStatusBar(), DoOpenFile(), and DoSaveFile().