ReactOS  0.4.15-dev-5462-g4d0d22a
dialog.c File Reference
#include "notepad.h"
#include <assert.h>
#include <commctrl.h>
#include <strsafe.h>
Include dependency graph for dialog.c:

Go to the source code of this file.

Macros

#define SBPART_CURPOS   0
 
#define SBPART_EOLN   1
 
#define SBPART_ENCODING   2
 

Typedefs

typedef HWND(WINAPIFINDPROC) (LPFINDREPLACE lpfr)
 

Functions

LRESULT CALLBACK EDIT_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 
VOID ShowLastError (VOID)
 
void UpdateWindowCaption (BOOL clearModifyAlert)
 
VOID DIALOG_StatusBarAlignParts (VOID)
 
static VOID DIALOG_StatusBarUpdateLineEndings (VOID)
 
static VOID DIALOG_StatusBarUpdateEncoding (VOID)
 
int DIALOG_StringMsgBox (HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
 
static void AlertFileNotFound (LPCTSTR szFileName)
 
static int AlertFileNotSaved (LPCTSTR szFileName)
 
static void AlertPrintError (void)
 
BOOL FileExists (LPCTSTR szFilename)
 
BOOL HasFileExtension (LPCTSTR szFilename)
 
int GetSelectionTextLength (HWND hWnd)
 
int GetSelectionText (HWND hWnd, LPTSTR lpString, int nMaxCount)
 
static RECT GetPrintingRect (HDC hdc, RECT margins)
 
static BOOL DoSaveFile (VOID)
 
BOOL DoCloseFile (VOID)
 
VOID DoOpenFile (LPCTSTR szFileName)
 
VOID DIALOG_FileNew (VOID)
 
VOID DIALOG_FileNewWindow (VOID)
 
VOID DIALOG_FileOpen (VOID)
 
BOOL DIALOG_FileSave (VOID)
 
static UINT_PTR CALLBACK DIALOG_FileSaveAs_Hook (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
 
BOOL DIALOG_FileSaveAs (VOID)
 
VOID DIALOG_FilePrint (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 DoCreateStatusBar (VOID)
 
VOID DoCreateEditWindow (VOID)
 
VOID DIALOG_EditWrap (VOID)
 
VOID DIALOG_SelectFont (VOID)
 
static VOID DIALOG_SearchDialog (FINDPROC pfnProc)
 
VOID DIALOG_Search (VOID)
 
VOID DIALOG_SearchNext (VOID)
 
VOID DIALOG_Replace (VOID)
 
static INT_PTR CALLBACK DIALOG_GoTo_DialogProc (HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
VOID DIALOG_GoTo (VOID)
 
VOID DIALOG_StatusBarUpdateCaretPos (VOID)
 
VOID DIALOG_ViewStatusBar (VOID)
 
VOID DIALOG_HelpContents (VOID)
 
VOID DIALOG_HelpAboutNotepad (VOID)
 
VOID DIALOG_FilePageSetup (void)
 

Variables

static const TCHAR helpfile [] = _T("notepad.hlp")
 
static const TCHAR empty_str [] = _T("")
 
static const TCHAR szDefaultExt [] = _T("txt")
 
static const TCHAR txt_files [] = _T("*.txt")
 
static UINT EolnToStrId []
 
static UINT EncToStrId []
 

Macro Definition Documentation

◆ SBPART_CURPOS

#define SBPART_CURPOS   0

Definition at line 37 of file dialog.c.

◆ SBPART_ENCODING

#define SBPART_ENCODING   2

Definition at line 39 of file dialog.c.

◆ SBPART_EOLN

#define SBPART_EOLN   1

Definition at line 38 of file dialog.c.

Typedef Documentation

◆ FINDPROC

typedef HWND(WINAPI * FINDPROC) (LPFINDREPLACE lpfr)

Definition at line 1141 of file dialog.c.

Function Documentation

◆ AlertFileNotFound()

static void AlertFileNotFound ( LPCTSTR  szFileName)
static

Definition at line 188 of file dialog.c.

189 {
191 }
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:167
#define MB_OK
Definition: winuser.h:784
#define STRING_NOTFOUND
Definition: notepad_res.h:87

Referenced by DIALOG_FileOpen().

◆ AlertFileNotSaved()

static int AlertFileNotSaved ( LPCTSTR  szFileName)
static

Definition at line 193 of file dialog.c.

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 }
#define MAX_STRING_LEN
Definition: precomp.h:36
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define STRING_NOTSAVED
Definition: notepad_res.h:85
#define MB_ICONQUESTION
Definition: winuser.h:783
#define MB_YESNOCANCEL
Definition: winuser.h:812
char TCHAR
Definition: xmlstorage.h:189
#define STRING_UNTITLED
Definition: notepad_res.h:79
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:167
#define ARRAY_SIZE(a)
Definition: main.h:24
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5809

Referenced by DoCloseFile().

◆ AlertPrintError()

static void AlertPrintError ( void  )
static

Definition at line 204 of file dialog.c.

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 }
#define MAX_STRING_LEN
Definition: precomp.h:36
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define STRING_PRINTERROR
Definition: notepad_res.h:102
char TCHAR
Definition: xmlstorage.h:189
#define STRING_UNTITLED
Definition: notepad_res.h:79
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:167
#define ARRAY_SIZE(a)
Definition: main.h:24
#define MB_OK
Definition: winuser.h:784
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5809

Referenced by DIALOG_FilePrint().

◆ DIALOG_EditCopy()

VOID DIALOG_EditCopy ( VOID  )

Definition at line 882 of file dialog.c.

883 {
884  SendMessage(Globals.hEdit, WM_COPY, 0, 0);
885 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define WM_COPY
Definition: winuser.h:1852
#define SendMessage
Definition: winuser.h:5833

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditCut()

VOID DIALOG_EditCut ( VOID  )

Definition at line 877 of file dialog.c.

878 {
879  SendMessage(Globals.hEdit, WM_CUT, 0, 0);
880 }
#define WM_CUT
Definition: winuser.h:1851
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SendMessage
Definition: winuser.h:5833

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditDelete()

VOID DIALOG_EditDelete ( VOID  )

Definition at line 892 of file dialog.c.

893 {
894  SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
895 }
#define WM_CLEAR
Definition: winuser.h:1854
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SendMessage
Definition: winuser.h:5833

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditPaste()

VOID DIALOG_EditPaste ( VOID  )

Definition at line 887 of file dialog.c.

888 {
889  SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
890 }
#define WM_PASTE
Definition: winuser.h:1853
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define SendMessage
Definition: winuser.h:5833

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditSelectAll()

VOID DIALOG_EditSelectAll ( VOID  )

Definition at line 897 of file dialog.c.

898 {
899  SendMessage(Globals.hEdit, EM_SETSEL, 0, (LPARAM)-1);
900 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG_PTR LPARAM
Definition: windef.h:208
#define EM_SETSEL
Definition: winuser.h:2008
#define SendMessage
Definition: winuser.h:5833

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditTimeDate()

VOID DIALOG_EditTimeDate ( VOID  )

Definition at line 902 of file dialog.c.

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 }
#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
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
#define GetTimeFormat
Definition: winnls.h:1189
#define GetDateFormat
Definition: winnls.h:1184
#define DATE_LONGDATE
Definition: winnls.h:197
#define NULL
Definition: types.h:112
#define SendMessage
Definition: winuser.h:5833
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
#define EM_REPLACESEL
Definition: winuser.h:1996

Referenced by DoOpenFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_EditUndo()

VOID DIALOG_EditUndo ( VOID  )

Definition at line 872 of file dialog.c.

873 {
874  SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
875 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define EM_UNDO
Definition: winuser.h:2011
#define SendMessage
Definition: winuser.h:5833

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditWrap()

VOID DIALOG_EditWrap ( VOID  )

Definition at line 1102 of file dialog.c.

1103 {
1104  Globals.bWrapLongLines = !Globals.bWrapLongLines;
1105 
1106  if (Globals.bWrapLongLines)
1107  {
1109  }
1110  else
1111  {
1113  }
1114 
1116 }
#define MF_DISABLED
Definition: winuser.h:130
#define MF_BYCOMMAND
Definition: winuser.h:202
#define CMD_GOTO
Definition: notepad_res.h:56
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:1000
#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 867 of file dialog.c.

868 {
870 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define PostMessage
Definition: winuser.h:5822
r l[0]
Definition: byte_order.h:167
#define WM_CLOSE
Definition: winuser.h:1611

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileNew()

VOID DIALOG_FileNew ( VOID  )

Definition at line 478 of file dialog.c.

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 }
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:388
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1975
#define SetWindowText
Definition: winuser.h:5847
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:34
#define SendMessage
Definition: winuser.h:5833

Referenced by _tWinMain(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileNewWindow()

VOID DIALOG_FileNewWindow ( VOID  )

Definition at line 489 of file dialog.c.

490 {
491  TCHAR pszNotepadExe[MAX_PATH];
492  GetModuleFileName(NULL, pszNotepadExe, ARRAYSIZE(pszNotepadExe));
493  ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL);
494 }
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ShellExecute
Definition: shellapi.h:691
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:34
#define GetModuleFileName
Definition: winbase.h:3702
#define SW_SHOWNORMAL
Definition: winuser.h:764
#define NULL
Definition: types.h:112

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileOpen()

VOID DIALOG_FileOpen ( VOID  )

Definition at line 496 of file dialog.c.

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 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_EXPLORER
Definition: commdlg.h:104
VOID DoOpenFile(LPCTSTR szFileName)
Definition: dialog.c:420
HWND hwndOwner
Definition: commdlg.h:330
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1670
LPCSTR lpstrDefExt
Definition: commdlg.h:345
static void AlertFileNotFound(LPCTSTR szFileName)
Definition: dialog.c:188
#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:220
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:37
#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 1308 of file dialog.c.

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 }
static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:1335
#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:1670
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 652 of file dialog.c.

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 }
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:445
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:1539
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define assert(x)
Definition: debug.h:53
#define ZeroMemory
Definition: winbase.h:1670
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:4474
LONG right
Definition: windef.h:308
#define PROOF_QUALITY
Definition: wingdi.h:438
CHAR * LPTSTR
Definition: xmlstorage.h:192
int WINAPI EndPage(_In_ HDC)
static RECT GetPrintingRect(HDC hdc, RECT margins)
Definition: dialog.c:309
BYTE lfOutPrecision
Definition: dimm.idl:51
WORD nMinPage
Definition: commdlg.h:473
#define GetWindowText
Definition: winuser.h:5788
int WINAPI StartPage(_In_ HDC)
#define PrintDlg
Definition: commdlg.h:668
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
int WINAPI SetMapMode(_In_ HDC, _In_ int)
LONG lfHeight
Definition: dimm.idl:42
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
LONG lfWeight
Definition: dimm.idl:46
WORD nFromPage
Definition: commdlg.h:471
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
#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:1680
VOID ShowLastError(VOID)
Definition: dialog.c:59
GLsizeiptr size
Definition: glext.h:5919
LPCSTR lpszOutput
Definition: wingdi.h:1678
#define GetProcessHeap()
Definition: compat.h:736
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:415
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:1679
#define PD_USEDEVMODECOPIES
Definition: commdlg.h:165
Definition: time.h:68
#define FF_ROMAN
Definition: wingdi.h:450
int cbSize
Definition: wingdi.h:1676
BYTE lfQuality
Definition: dimm.idl:53
HWND hwndOwner
Definition: commdlg.h:466
#define lstrlen
Definition: winbase.h:3747
#define FW_BOLD
Definition: wingdi.h:378
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
BOOL WINAPI DeleteDC(_In_ HDC)
LPCSTR lpszDocName
Definition: wingdi.h:1677
BYTE lfClipPrecision
Definition: dimm.idl:52
HGLOBAL hDevNames
Definition: commdlg.h:468
#define CreateFontIndirect
Definition: wingdi.h:4444
#define NULL
Definition: types.h:112
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:873
#define GetTextExtentPoint32
Definition: wingdi.h:4472
#define TextOut
Definition: wingdi.h:4483
#define GetWindowTextLength
Definition: winuser.h:5789
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:4482
static void AlertPrintError(void)
Definition: dialog.c:204
int GetSelectionTextLength(HWND hWnd)
Definition: dialog.c:241
#define ANSI_CHARSET
Definition: wingdi.h:383
HINSTANCE hInstance
Definition: precomp.h:43
HDC hDC
Definition: commdlg.h:469
#define HeapFree(x, y, z)
Definition: compat.h:735
DOCINFOA DOCINFO
Definition: wingdi.h:4414
int WINAPI EndDoc(_In_ HDC)

Referenced by HandleCommandLine(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileSave()

BOOL DIALOG_FileSave ( VOID  )

Definition at line 525 of file dialog.c.

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 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:87
static BOOL DoSaveFile(VOID)
Definition: dialog.c:333
#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:600

Referenced by DoCloseFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileSaveAs()

BOOL DIALOG_FileSaveAs ( VOID  )

Definition at line 600 of file dialog.c.

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 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:87
#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:541
HWND hwndOwner
Definition: commdlg.h:330
static BOOL DoSaveFile(VOID)
Definition: dialog.c:333
#define TRUE
Definition: types.h:120
static VOID DIALOG_StatusBarUpdateLineEndings(VOID)
Definition: dialog.c:146
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
#define ZeroMemory
Definition: winbase.h:1670
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:180
#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
static VOID DIALOG_StatusBarUpdateEncoding(VOID)
Definition: dialog.c:155
LPSTR lpstrFile
Definition: commdlg.h:336
LPCWSTR szPath
Definition: env.c:37
#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_FileSaveAs_Hook()

static UINT_PTR CALLBACK DIALOG_FileSaveAs_Hook ( HWND  hDlg,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 541 of file dialog.c.

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 }
#define STRING_LF
Definition: notepad_res.h:98
#define STRING_ANSI
Definition: notepad_res.h:91
#define STRING_UTF8
Definition: notepad_res.h:94
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define STRING_UTF8_BOM
Definition: notepad_res.h:95
#define CB_GETCURSEL
Definition: winuser.h:1933
WPARAM wParam
Definition: combotst.c:138
#define ID_ENCODING
Definition: notepad_res.h:28
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define CB_ADDSTRING
Definition: winuser.h:1926
LONG_PTR LPARAM
Definition: windef.h:208
#define STRING_UNICODE_BE
Definition: notepad_res.h:93
#define STRING_CRLF
Definition: notepad_res.h:97
char TCHAR
Definition: xmlstorage.h:189
#define CDN_FILEOK
Definition: commdlg.h:38
#define ID_EOLN
Definition: notepad_res.h:29
#define CB_SETCURSEL
Definition: winuser.h:1951
Definition: inflate.c:139
ENCODING
Definition: more.c:491
#define ARRAY_SIZE(a)
Definition: main.h:24
#define msg(x)
Definition: auth_time.c:54
#define STRING_UNICODE
Definition: notepad_res.h:92
#define SendMessage
Definition: winuser.h:5833
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem)
Definition: dialog.c:2181
HINSTANCE hInstance
Definition: precomp.h:43
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define STRING_CR
Definition: notepad_res.h:99
#define LoadString
Definition: winuser.h:5809
#define WM_NOTIFY
Definition: richedit.h:61
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by DIALOG_FileSaveAs().

◆ DIALOG_GoTo()

VOID DIALOG_GoTo ( VOID  )

Definition at line 1222 of file dialog.c.

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 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
_In_ DWORD nLength
Definition: wincon.h:473
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:5788
#define EM_GETSEL
Definition: winuser.h:1987
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG_PTR LPARAM
Definition: windef.h:208
#define DIALOG_GOTO
Definition: notepad_res.h:30
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define EM_SETSEL
Definition: winuser.h:2008
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DialogBoxParam
Definition: winuser.h:5754
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
#define SendMessage
Definition: winuser.h:5833
#define GetWindowTextLength
Definition: winuser.h:5789
HINSTANCE hInstance
Definition: precomp.h:43
#define HeapFree(x, y, z)
Definition: compat.h:735
#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:1188

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_GoTo_DialogProc()

static INT_PTR CALLBACK DIALOG_GoTo_DialogProc ( HWND  hwndDialog,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1188 of file dialog.c.

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 }
#define IDOK
Definition: winuser.h:824
#define TRUE
Definition: types.h:120
WPARAM wParam
Definition: combotst.c:138
#define GetWindowText
Definition: winuser.h:5788
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define BN_CLICKED
Definition: winuser.h:1915
#define _sntprintf
Definition: xmlstorage.h:201
#define WM_COMMAND
Definition: winuser.h:1730
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2083
#define ARRAY_SIZE(a)
Definition: main.h:24
int CDECL _ttoi(const _TCHAR *str)
Definition: atoi.c:10
#define SetWindowText
Definition: winuser.h:5847
#define ID_LINENUMBER
Definition: notepad_res.h:31
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem)
Definition: dialog.c:2181
#define HIWORD(l)
Definition: typedefs.h:247
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1729
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DIALOG_GoTo().

◆ DIALOG_HelpAboutNotepad()

VOID DIALOG_HelpAboutNotepad ( VOID  )

Definition at line 1290 of file dialog.c.

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 }
#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:107
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define STRING_NOTEPAD
Definition: notepad_res.h:75
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:5803
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5809

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_HelpContents()

VOID DIALOG_HelpContents ( VOID  )

Definition at line 1285 of file dialog.c.

1286 {
1288 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define HELP_INDEX
Definition: winuser.h:2400
static const TCHAR helpfile[]
Definition: dialog.c:31
#define WinHelp
Definition: winuser.h:5854

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_PAGESETUP_Hook()

static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook ( HWND  hDlg,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1335 of file dialog.c.

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 IDOK
Definition: winuser.h:824
#define TRUE
Definition: types.h:120
WPARAM wParam
Definition: combotst.c:138
#define IDHELP
Definition: resource_2.h:8
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FALSE
Definition: types.h:117
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define GetDlgItemText
Definition: winuser.h:5775
#define BN_CLICKED
Definition: winuser.h:1915
#define SetDlgItemText
Definition: winuser.h:5839
#define MessageBox
Definition: winuser.h:5812
#define WM_COMMAND
Definition: winuser.h:1730
#define ARRAY_SIZE(a)
Definition: main.h:24
#define msg(x)
Definition: auth_time.c:54
#define HIWORD(l)
Definition: typedefs.h:247
#define IDCANCEL
Definition: winuser.h:825
int help
Definition: sort.c:20
#define WM_INITDIALOG
Definition: winuser.h:1729
#define LOWORD(l)
Definition: pedump.c:82

Referenced by DIALOG_FilePageSetup().

◆ DIALOG_Replace()

VOID DIALOG_Replace ( VOID  )

Definition at line 1181 of file dialog.c.

1182 {
1184 }
#define ReplaceText
Definition: commdlg.h:669
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:1143

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_Search()

VOID DIALOG_Search ( VOID  )

Definition at line 1168 of file dialog.c.

1169 {
1171 }
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:1143
#define FindText
Definition: commdlg.h:663

Referenced by DIALOG_SearchNext(), and NOTEPAD_MenuCommand().

◆ DIALOG_SearchDialog()

static VOID DIALOG_SearchDialog ( FINDPROC  pfnProc)
static

Definition at line 1143 of file dialog.c.

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 }
#define assert(x)
Definition: debug.h:53
#define ZeroMemory
Definition: winbase.h:1670
HWND WINAPI SetFocus(_In_opt_ HWND)
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define ARRAY_SIZE(a)
Definition: main.h:24
#define NULL
Definition: types.h:112
#define FR_DOWN
Definition: commdlg.h:127
HINSTANCE hInstance
Definition: precomp.h:43

Referenced by DIALOG_Replace(), and DIALOG_Search().

◆ DIALOG_SearchNext()

VOID DIALOG_SearchNext ( VOID  )

Definition at line 1173 of file dialog.c.

1174 {
1175  if (Globals.find.lpstrFindWhat != NULL)
1177  else
1178  DIALOG_Search();
1179 }
VOID DIALOG_Search(VOID)
Definition: dialog.c:1168
#define TRUE
Definition: types.h:120
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:144
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FALSE
Definition: types.h:117
#define NULL
Definition: types.h:112

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_SelectFont()

VOID DIALOG_SelectFont ( VOID  )

Definition at line 1118 of file dialog.c.

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 }
static IClassFactory * cf
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1670
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
LONG_PTR LPARAM
Definition: windef.h:208
#define CreateFontIndirect
Definition: wingdi.h:4444
#define NULL
Definition: types.h:112
#define WM_SETFONT
Definition: winuser.h:1640
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define SendMessage
Definition: winuser.h:5833
#define CF_NOVERTFONTS
Definition: commdlg.h:86
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_StatusBarAlignParts()

VOID DIALOG_StatusBarAlignParts ( VOID  )

Definition at line 128 of file dialog.c.

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 }
#define max(a, b)
Definition: svc.c:63
static const D3D_BLOB_PART parts[]
Definition: blob.c:76
UINT_PTR WPARAM
Definition: windef.h:207
LONG right
Definition: windef.h:308
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_SETPARTS
Definition: commctrl.h:1954

Referenced by DoCreateStatusBar(), and NOTEPAD_WndProc().

◆ DIALOG_StatusBarUpdateCaretPos()

VOID DIALOG_StatusBarUpdateCaretPos ( VOID  )

Definition at line 1264 of file dialog.c.

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 }
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_GETSEL
Definition: winuser.h:1987
#define SBPART_CURPOS
Definition: dialog.c:37
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
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
#define SB_SETTEXT
Definition: commctrl.h:1949
IN PCTCH line
Definition: pager.h:36
#define _stprintf
Definition: utility.h:124
#define EM_LINEFROMCHAR
Definition: winuser.h:1991
#define SendMessage
Definition: winuser.h:5833
#define EM_LINEINDEX
Definition: winuser.h:1992
static unsigned char buff[32768]
Definition: fatten.c:17
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

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

◆ DIALOG_StatusBarUpdateEncoding()

static VOID DIALOG_StatusBarUpdateEncoding ( VOID  )
static

Definition at line 155 of file dialog.c.

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 }
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define L(x)
Definition: ntvdm.h:50
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
static UINT EncToStrId[]
Definition: dialog.c:49
#define SB_SETTEXTW
Definition: commctrl.h:1942
#define SBPART_ENCODING
Definition: dialog.c:39
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HINSTANCE hInstance
Definition: precomp.h:43

Referenced by DIALOG_FileSaveAs(), DoCreateStatusBar(), and DoOpenFile().

◆ DIALOG_StatusBarUpdateLineEndings()

static VOID DIALOG_StatusBarUpdateLineEndings ( VOID  )
static

Definition at line 146 of file dialog.c.

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 }
static UINT EolnToStrId[]
Definition: dialog.c:42
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LONG_PTR LPARAM
Definition: windef.h:208
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define SB_SETTEXTW
Definition: commctrl.h:1942
#define SBPART_EOLN
Definition: dialog.c:38
#define ARRAY_SIZE(a)
Definition: main.h:24
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HINSTANCE hInstance
Definition: precomp.h:43

Referenced by DIALOG_FileSaveAs(), DoCreateStatusBar(), and DoOpenFile().

◆ DIALOG_StringMsgBox()

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

Definition at line 167 of file dialog.c.

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 }
#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:75
char TCHAR
Definition: xmlstorage.h:189
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define _sntprintf
Definition: xmlstorage.h:201
#define MessageBox
Definition: winuser.h:5812
#define ARRAY_SIZE(a)
Definition: main.h:24
#define STRING_ERROR
Definition: notepad_res.h:76
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5809

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

◆ DIALOG_ViewStatusBar()

VOID DIALOG_ViewStatusBar ( VOID  )

Definition at line 1278 of file dialog.c.

1279 {
1280  Globals.bShowStatusBar = !Globals.bShowStatusBar;
1281 
1283 }
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
VOID DoCreateStatusBar(VOID)
Definition: dialog.c:918

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 388 of file dialog.c.

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 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:87
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:180
#define EM_GETMODIFY
Definition: winuser.h:1984
#define SendMessage
Definition: winuser.h:5833
#define IDNO
Definition: winuser.h:830
#define IDCANCEL
Definition: winuser.h:825
static int AlertFileNotSaved(LPCTSTR szFileName)
Definition: dialog.c:193
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:525

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

◆ DoCreateEditWindow()

VOID DoCreateEditWindow ( VOID  )

Definition at line 1000 of file dialog.c.

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 }
#define EM_LIMITTEXT
Definition: winuser.h:1990
#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:5788
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define CMD_STATUSBAR
Definition: notepad_res.h:61
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:5745
#define CW_USEDEFAULT
Definition: winuser.h:225
VOID DoCreateStatusBar(VOID)
Definition: dialog.c:918
#define SW_SHOW
Definition: winuser.h:769
char TCHAR
Definition: xmlstorage.h:189
VOID ShowLastError(VOID)
Definition: dialog.c:59
#define GetProcessHeap()
Definition: compat.h:736
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:1984
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EM_SETMODIFY
Definition: winuser.h:2003
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2896
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:310
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define SetWindowText
Definition: winuser.h:5847
#define NULL
Definition: types.h:112
#define WM_SETFONT
Definition: winuser.h:1640
#define SendMessage
Definition: winuser.h:5833
#define EDIT_STYLE_WRAP
Definition: main.h:28
#define EDIT_STYLE
Definition: main.h:30
#define GetWindowTextLength
Definition: winuser.h:5789
#define MF_GRAYED
Definition: winuser.h:129
HINSTANCE hInstance
Definition: precomp.h:43
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by _tWinMain(), and DIALOG_EditWrap().

◆ DoCreateStatusBar()

VOID DoCreateStatusBar ( VOID  )

Definition at line 918 of file dialog.c.

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 }
#define STRING_LINE_COLUMN
Definition: notepad_res.h:101
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
static VOID DIALOG_StatusBarUpdateLineEndings(VOID)
Definition: dialog.c:146
LONG top
Definition: windef.h:307
#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:61
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CreateStatusWindow
Definition: commctrl.h:1933
#define SW_SHOW
Definition: winuser.h:769
#define CCS_BOTTOM
Definition: commctrl.h:2244
#define MF_CHECKED
Definition: winuser.h:132
VOID ShowLastError(VOID)
Definition: dialog.c:59
#define SBARS_SIZEGRIP
Definition: commctrl.h:1923
#define WM_SIZE
Definition: winuser.h:1601
#define MAX_PATH
Definition: compat.h:34
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:1264
DWORD WINAPI CheckMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
static VOID DIALOG_StatusBarUpdateEncoding(VOID)
Definition: dialog.c:155
#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 NULL
Definition: types.h:112
#define SendMessage
Definition: winuser.h:5833
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:62
#define LoadString
Definition: winuser.h:5809
VOID DIALOG_StatusBarAlignParts(VOID)
Definition: dialog.c:128

Referenced by DIALOG_ViewStatusBar(), and DoCreateEditWindow().

◆ DoOpenFile()

VOID DoOpenFile ( LPCTSTR  szFileName)

Definition at line 420 of file dialog.c.

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 }
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:87
#define CloseHandle
Definition: compat.h:739
int _tcscmp(const _TCHAR *s1, const _TCHAR *s2)
Definition: tcscmp.h:8
#define TRUE
Definition: types.h:120
static VOID DIALOG_StatusBarUpdateLineEndings(VOID)
Definition: dialog.c:146
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
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:5788
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:388
LONG_PTR LPARAM
Definition: windef.h:208
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:180
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
VOID ShowLastError(VOID)
Definition: dialog.c:59
#define GetProcessHeap()
Definition: compat.h:736
#define EM_SETSEL
Definition: winuser.h:2008
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:1975
#define GENERIC_READ
Definition: compat.h:135
#define EM_SETMODIFY
Definition: winuser.h:2003
static VOID DIALOG_StatusBarUpdateEncoding(VOID)
Definition: dialog.c:155
_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:5847
#define NULL
Definition: types.h:112
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:34
#define SendMessage
Definition: winuser.h:5833
#define GetWindowTextLength
Definition: winuser.h:5789
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:902
#define HeapFree(x, y, z)
Definition: compat.h:735
#define log(outFile, fmt,...)
Definition: util.h:15
#define EM_REPLACESEL
Definition: winuser.h:1996

Referenced by DIALOG_FileOpen().

◆ DoSaveFile()

static BOOL DoSaveFile ( VOID  )
static

Definition at line 333 of file dialog.c.

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 }
#define CloseHandle
Definition: compat.h:739
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, int iEoln)
Definition: text.c:370
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define GetWindowText
Definition: winuser.h:5788
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GENERIC_WRITE
Definition: nt_native.h:90
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:180
VOID ShowLastError(VOID)
Definition: dialog.c:59
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define EM_SETMODIFY
Definition: winuser.h:2003
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define NULL
Definition: types.h:112
#define SendMessage
Definition: winuser.h:5833
#define GetWindowTextLength
Definition: winuser.h:5789
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by DIALOG_FileSave(), and DIALOG_FileSaveAs().

◆ EDIT_WndProc()

LRESULT CALLBACK EDIT_WndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 310 of file main.c.

311 {
312  switch (msg)
313  {
314  case WM_KEYDOWN:
315  case WM_KEYUP:
316  {
317  switch (wParam)
318  {
319  case VK_UP:
320  case VK_DOWN:
321  case VK_LEFT:
322  case VK_RIGHT:
324  break;
325  default:
326  {
328  break;
329  }
330  }
331  }
332  case WM_LBUTTONUP:
333  {
335  break;
336  }
337  }
339 }
#define CallWindowProc
Definition: winuser.h:5725
NOTEPAD_GLOBALS Globals
Definition: main.c:31
HWND hWnd
Definition: settings.c:17
#define VK_LEFT
Definition: winuser.h:2214
#define VK_DOWN
Definition: winuser.h:2217
WNDPROC EditProc
Definition: main.h:82
WPARAM wParam
Definition: combotst.c:138
#define VK_UP
Definition: winuser.h:2215
#define FALSE
Definition: types.h:117
#define WM_KEYDOWN
Definition: winuser.h:1705
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:1264
#define WM_KEYUP
Definition: winuser.h:1706
#define VK_RIGHT
Definition: winuser.h:2216
#define WM_LBUTTONUP
Definition: winuser.h:1767
#define msg(x)
Definition: auth_time.c:54
LPARAM lParam
Definition: combotst.c:139
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:102

Referenced by DoCreateEditWindow().

◆ FileExists()

BOOL FileExists ( LPCTSTR  szFilename)

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

Definition at line 220 of file dialog.c.

221 {
223  HANDLE hFile;
224 
225  hFile = FindFirstFile(szFilename, &entry);
226  FindClose(hFile);
227 
228  return (hFile != INVALID_HANDLE_VALUE);
229 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define FindFirstFile
Definition: winbase.h:3653
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().

◆ GetPrintingRect()

static RECT GetPrintingRect ( HDC  hdc,
RECT  margins 
)
static

Definition at line 309 of file dialog.c.

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 }
#define HORZRES
Definition: wingdi.h:716
#define LOGPIXELSX
Definition: wingdi.h:718
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define PHYSICALHEIGHT
Definition: wingdi.h:736
#define PHYSICALOFFSETY
Definition: wingdi.h:738
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
static RECT margins
Definition: print.c:55
#define PHYSICALOFFSETX
Definition: wingdi.h:737
#define PHYSICALWIDTH
Definition: wingdi.h:735
#define VERTRES
Definition: wingdi.h:717
LONG bottom
Definition: windef.h:309
#define LOGPIXELSY
Definition: wingdi.h:719

Referenced by DIALOG_FilePrint().

◆ GetSelectionText()

int GetSelectionText ( HWND  hWnd,
LPTSTR  lpString,
int  nMaxCount 
)

Definition at line 251 of file dialog.c.

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 }
HWND hWnd
Definition: settings.c:17
#define StringCchCopyN
Definition: strsafe.h:227
UINT_PTR WPARAM
Definition: windef.h:207
#define STRSAFE_E_INSUFFICIENT_BUFFER
Definition: strsafe.h:103
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define GetWindowText
Definition: winuser.h:5788
#define EM_GETSEL
Definition: winuser.h:1987
LONG_PTR LPARAM
Definition: windef.h:208
char TCHAR
Definition: xmlstorage.h:189
#define GetProcessHeap()
Definition: compat.h:736
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:52
#define SendMessage
Definition: winuser.h:5833
#define GetWindowTextLength
Definition: winuser.h:5789
_In_ int nMaxCount
Definition: winuser.h:4867
#define HeapFree(x, y, z)
Definition: compat.h:735
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56

Referenced by DIALOG_FilePrint().

◆ GetSelectionTextLength()

int GetSelectionTextLength ( HWND  hWnd)

Definition at line 241 of file dialog.c.

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 }
HWND hWnd
Definition: settings.c:17
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_GETSEL
Definition: winuser.h:1987
LONG_PTR LPARAM
Definition: windef.h:208
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SendMessage
Definition: winuser.h:5833

Referenced by DIALOG_FilePrint().

◆ HasFileExtension()

BOOL HasFileExtension ( LPCTSTR  szFilename)

Definition at line 231 of file dialog.c.

232 {
233  LPCTSTR s;
234 
235  s = _tcsrchr(szFilename, _T('\\'));
236  if (s)
237  szFilename = s;
238  return _tcsrchr(szFilename, _T('.')) != NULL;
239 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define _T(x)
Definition: vfdio.h:22
GLdouble s
Definition: gl.h:2039
#define NULL
Definition: types.h:112
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4

Referenced by HandleCommandLine().

◆ ShowLastError()

VOID ShowLastError ( VOID  )

Definition at line 59 of file dialog.c.

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 }
#define error(str)
Definition: mkdosfs.c:1605
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#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:419
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
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:3666
#define MB_ICONERROR
Definition: winuser.h:781
#define MessageBox
Definition: winuser.h:5812
#define ARRAY_SIZE(a)
Definition: main.h:24
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define STRING_ERROR
Definition: notepad_res.h:76
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5809

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

◆ UpdateWindowCaption()

void UpdateWindowCaption ( BOOL  clearModifyAlert)

Sets the caption of the main window according to Globals.szFileTitle: (untitled) - Notepad if no file is open [filename] - Notepad if a file is given

Definition at line 87 of file dialog.c.

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 }
#define MAX_STRING_LEN
Definition: precomp.h:36
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define STRING_NOTEPAD
Definition: notepad_res.h:75
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define STRING_UNTITLED
Definition: notepad_res.h:79
#define StringCbPrintf
Definition: strsafe.h:544
#define EM_GETMODIFY
Definition: winuser.h:1984
#define StringCchCopy
Definition: strsafe.h:139
#define ARRAY_SIZE(a)
Definition: main.h:24
#define SetWindowText
Definition: winuser.h:5847
#define SendMessage
Definition: winuser.h:5833
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5809

Referenced by DIALOG_FileSave(), DIALOG_FileSaveAs(), DoCloseFile(), and DoOpenFile().

Variable Documentation

◆ empty_str

◆ EncToStrId

UINT EncToStrId[]
static
Initial value:
= {
}
#define STRING_ANSI
Definition: notepad_res.h:91
#define STRING_UTF8
Definition: notepad_res.h:94
#define STRING_UTF8_BOM
Definition: notepad_res.h:95
#define STRING_UNICODE_BE
Definition: notepad_res.h:93
#define STRING_UNICODE
Definition: notepad_res.h:92

Definition at line 49 of file dialog.c.

Referenced by DIALOG_StatusBarUpdateEncoding().

◆ EolnToStrId

UINT EolnToStrId[]
static
Initial value:
= {
}
#define STRING_LF
Definition: notepad_res.h:98
#define STRING_CRLF
Definition: notepad_res.h:97
#define STRING_CR
Definition: notepad_res.h:99

Definition at line 42 of file dialog.c.

Referenced by DIALOG_StatusBarUpdateLineEndings().

◆ helpfile

const TCHAR helpfile[] = _T("notepad.hlp")
static

◆ szDefaultExt

const TCHAR szDefaultExt[] = _T("txt")
static

Definition at line 33 of file dialog.c.

Referenced by DIALOG_FileOpen(), and DIALOG_FileSaveAs().

◆ txt_files

const TCHAR txt_files[] = _T("*.txt")
static

Definition at line 34 of file dialog.c.

Referenced by DIALOG_FileOpen(), DIALOG_FileSaveAs(), and NOTEPAD_InitData().