ReactOS 0.4.16-dev-13-ge2fc578
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_FileNewWindow (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 (BOOL bDown)
 
VOID DIALOG_Replace (VOID)
 
VOID DIALOG_GoTo (VOID)
 
VOID DIALOG_SelectFont (VOID)
 
VOID DIALOG_ViewStatusBar (VOID)
 
VOID DIALOG_StatusBarAlignParts (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 DoShowHideStatusBar (VOID)
 
VOID DoCreateEditWindow (VOID)
 
void UpdateWindowCaption (BOOL clearModifyAlert)
 
VOID WaitCursor (BOOL bBegin)
 

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;
11 TCHAR strLicense[700];
12
13 switch (message)
14 {
15 case WM_INITDIALOG:
16
20 16,
21 16,
22 0);
23
24 SendMessage(hDlg,
25 WM_SETICON,
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 IDC_LICENSE_EDIT
Definition: resource.h:20
#define IDI_ICON
Definition: resource.h:5
#define IDS_LICENSE
Definition: resource.h:28
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
#define LOWORD(l)
Definition: pedump.c:82
Definition: tftpd.h:60
#define ICON_SMALL
Definition: tnclass.cpp:48
LONG_PTR LPARAM
Definition: windef.h:208
#define IDCANCEL
Definition: winuser.h:834
#define IMAGE_ICON
Definition: winuser.h:212
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:833
#define SendMessage
Definition: winuser.h:5855
#define LoadImage
Definition: winuser.h:5827
#define LoadString
Definition: winuser.h:5831
#define SetWindowText
Definition: winuser.h:5869
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2097
char TCHAR
Definition: xmlstorage.h:189

◆ DIALOG_EditCopy()

VOID DIALOG_EditCopy ( VOID  )

Definition at line 595 of file dialog.c.

596{
597 SendMessage(Globals.hEdit, WM_COPY, 0, 0);
598}
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define WM_COPY
Definition: winuser.h:1865

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditCut()

VOID DIALOG_EditCut ( VOID  )

Definition at line 590 of file dialog.c.

591{
592 SendMessage(Globals.hEdit, WM_CUT, 0, 0);
593}
#define WM_CUT
Definition: winuser.h:1864

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditDelete()

VOID DIALOG_EditDelete ( VOID  )

Definition at line 605 of file dialog.c.

606{
607 SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
608}
#define WM_CLEAR
Definition: winuser.h:1867

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditPaste()

VOID DIALOG_EditPaste ( VOID  )

Definition at line 600 of file dialog.c.

601{
602 SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
603}
#define WM_PASTE
Definition: winuser.h:1866

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditSelectAll()

VOID DIALOG_EditSelectAll ( VOID  )

Definition at line 610 of file dialog.c.

611{
612 SendMessage(Globals.hEdit, EM_SETSEL, 0, -1);
613}
#define EM_SETSEL
Definition: winuser.h:2021

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditTimeDate()

VOID DIALOG_EditTimeDate ( VOID  )

Definition at line 615 of file dialog.c.

616{
617 SYSTEMTIME st;
618 TCHAR szDate[MAX_STRING_LEN];
619 TCHAR szText[MAX_STRING_LEN * 2 + 2];
620
621 GetLocalTime(&st);
622
624 _tcscpy(szText, szDate);
625 _tcscat(szText, _T(" "));
627 _tcscat(szText, szDate);
628 SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szText);
629}
#define MAX_STRING_LEN
Definition: precomp.h:36
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:286
#define _tcscat
Definition: tchar.h:622
#define _tcscpy
Definition: tchar.h:623
#define LOCALE_USER_DEFAULT
#define _T(x)
Definition: vfdio.h:22
#define GetTimeFormat
Definition: winnls.h:1189
#define DATE_LONGDATE
Definition: winnls.h:197
#define GetDateFormat
Definition: winnls.h:1184
#define EM_REPLACESEL
Definition: winuser.h:2009

Referenced by DoOpenFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_EditUndo()

VOID DIALOG_EditUndo ( VOID  )

Definition at line 585 of file dialog.c.

586{
587 SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
588}
#define EM_UNDO
Definition: winuser.h:2024

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditWrap()

VOID DIALOG_EditWrap ( VOID  )

Definition at line 756 of file dialog.c.

757{
758 Globals.bWrapLongLines = !Globals.bWrapLongLines;
759
761
764}
VOID DoShowHideStatusBar(VOID)
Definition: dialog.c:631
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:665
#define CMD_GOTO
Definition: notepad_res.h:47
#define MF_ENABLED
Definition: winuser.h:128
BOOL WINAPI EnableMenuItem(_In_ HMENU, _In_ UINT, _In_ UINT)
#define MF_GRAYED
Definition: winuser.h:129

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileExit()

VOID DIALOG_FileExit ( VOID  )

Definition at line 580 of file dialog.c.

581{
583}
#define WM_CLOSE
Definition: winuser.h:1624
#define PostMessage
Definition: winuser.h:5844

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileNew()

VOID DIALOG_FileNew ( VOID  )

Definition at line 397 of file dialog.c.

398{
399 /* Close any files and prompt to save changes */
400 if (!DoCloseFile())
401 return;
402
404
405 SetWindowText(Globals.hEdit, NULL);
407 Globals.iEoln = EOLN_CRLF;
408 Globals.encFile = ENCODING_DEFAULT;
409
412
414}
VOID WaitCursor(BOOL bBegin)
Definition: dialog.c:120
static VOID DIALOG_StatusBarUpdateAll(VOID)
Definition: dialog.c:186
BOOL DoCloseFile(VOID)
Definition: dialog.c:311
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:20
#define ENCODING_DEFAULT
Definition: notepad.h:49
@ EOLN_CRLF
Definition: notepad.h:53
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1988

Referenced by NOTEPAD_MenuCommand(), and NOTEPAD_WndProc().

◆ DIALOG_FileNewWindow()

VOID DIALOG_FileNewWindow ( VOID  )

Definition at line 416 of file dialog.c.

417{
418 TCHAR pszNotepadExe[MAX_PATH];
419
421
422 GetModuleFileName(NULL, pszNotepadExe, _countof(pszNotepadExe));
423 ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL);
424
426}
#define MAX_PATH
Definition: compat.h:34
#define ShellExecute
Definition: shellapi.h:693
#define _countof(array)
Definition: sndvol32.h:70
#define GetModuleFileName
Definition: winbase.h:3831
#define SW_SHOWNORMAL
Definition: winuser.h:773

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileOpen()

VOID DIALOG_FileOpen ( VOID  )

Definition at line 428 of file dialog.c.

429{
430 OPENFILENAME openfilename;
432
433 ZeroMemory(&openfilename, sizeof(openfilename));
434
435 if (Globals.szFileName[0] == 0)
437 else
438 _tcscpy(szPath, Globals.szFileName);
439
440 openfilename.lStructSize = sizeof(openfilename);
441 openfilename.hwndOwner = Globals.hMainWnd;
442 openfilename.hInstance = Globals.hInstance;
443 openfilename.lpstrFilter = Globals.szFilter;
444 openfilename.lpstrFile = szPath;
445 openfilename.nMaxFile = _countof(szPath);
447 openfilename.lpstrDefExt = szDefaultExt;
448
449 if (GetOpenFileName(&openfilename)) {
450 if (FileExists(openfilename.lpstrFile))
451 DoOpenFile(openfilename.lpstrFile);
452 else
453 AlertFileNotFound(openfilename.lpstrFile);
454 }
455}
static void AlertFileNotFound(LPCTSTR szFileName)
Definition: dialog.c:214
static const TCHAR txt_files[]
Definition: dialog.c:22
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:235
static const TCHAR szDefaultExt[]
Definition: dialog.c:21
VOID DoOpenFile(LPCTSTR szFileName)
Definition: dialog.c:341
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define GetOpenFileName
Definition: commdlg.h:665
LPCWSTR szPath
Definition: env.c:37
HINSTANCE hInstance
Definition: precomp.h:43
LPCSTR lpstrDefExt
Definition: commdlg.h:345
HWND hwndOwner
Definition: commdlg.h:330
HINSTANCE hInstance
Definition: commdlg.h:331
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
#define ZeroMemory
Definition: winbase.h:1712

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FilePageSetup()

VOID DIALOG_FilePageSetup ( VOID  )

Definition at line 670 of file printing.c.

671{
673
674 ZeroMemory(&page, sizeof(page));
675 page.lStructSize = sizeof(page);
676 page.hwndOwner = Globals.hMainWnd;
678 page.hInstance = Globals.hInstance;
679 page.rtMargin = Globals.lMargins;
680 page.hDevMode = Globals.hDevMode;
681 page.hDevNames = Globals.hDevNames;
682 page.lpPageSetupTemplateName = MAKEINTRESOURCE(DIALOG_PAGESETUP);
683 page.lpfnPageSetupHook = DIALOG_PAGESETUP_Hook;
684
686
687 /* NOTE: Even if PageSetupDlg returns FALSE, the following members may have changed */
688 Globals.hDevMode = page.hDevMode;
689 Globals.hDevNames = page.hDevNames;
690 Globals.lMargins = page.rtMargin;
691}
#define PSD_ENABLEPAGESETUPHOOK
Definition: commdlg.h:183
#define PSD_ENABLEPAGESETUPTEMPLATE
Definition: commdlg.h:184
#define PSD_MARGINS
Definition: commdlg.h:173
#define PageSetupDlg
Definition: commdlg.h:667
#define DIALOG_PAGESETUP
Definition: notepad_res.h:12
static UINT_PTR CALLBACK DIALOG_PAGESETUP_Hook(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printing.c:621
Definition: module.h:576

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FilePrint()

VOID DIALOG_FilePrint ( VOID  )

Definition at line 565 of file printing.c.

566{
567 BOOL ret;
568 LPPRINTDLG printer;
569 PPRINT_DATA printData = LocalAlloc(LPTR, sizeof(PRINT_DATA));
570 if (!printData)
571 {
573 return;
574 }
575
576 printer = &printData->printer;
577 printer->lStructSize = sizeof(PRINTDLG);
578 printer->hwndOwner = Globals.hMainWnd;
579 printer->Flags = PD_RETURNDC | PD_SELECTION;
580
581 /* Disable the selection radio button if there is no text selected */
583 printer->Flags |= PD_NOSELECTION;
584
585 printer->nFromPage = 1;
586 printer->nToPage = MAXWORD;
587 printer->nMinPage = 1;
588 printer->nMaxPage = MAXWORD;
589
590 printer->hDevMode = Globals.hDevMode;
591 printer->hDevNames = Globals.hDevNames;
592
593 ret = PrintDlg(printer);
594 /* NOTE: Even if PrintDlg returns FALSE, hDevMode and hDevNames may have changed. */
595 Globals.hDevMode = printer->hDevMode;
596 Globals.hDevNames = printer->hDevNames;
597
598 if (!ret)
599 {
600 LocalFree(printData);
601 return; /* The user canceled printing */
602 }
603 assert(printer->hDC != NULL);
604
605 /* Ensure that each logical unit maps to one pixel */
606 SetMapMode(printer->hDC, MM_TEXT);
607
612 (LPARAM)printer) == IDABORT)
613 {
615 }
616}
VOID ShowLastError(VOID)
Definition: dialog.c:45
#define PD_NOSELECTION
Definition: commdlg.h:149
#define PD_SELECTION
Definition: commdlg.h:147
#define PrintDlg
Definition: commdlg.h:668
#define PD_RETURNDC
Definition: commdlg.h:155
PRINTDLGA PRINTDLG
Definition: commdlg.h:660
#define assert(x)
Definition: debug.h:53
unsigned int BOOL
Definition: ntddk_ex.h:94
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define DIALOG_PRINTING
Definition: notepad_res.h:21
#define MAXWORD
static INT_PTR CALLBACK DIALOG_Printing_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printing.c:493
static INT GetSelectionTextLength(HWND hWnd)
Definition: printing.c:57
static VOID AlertPrintError(VOID)
Definition: printing.c:16
PRINTDLG printer
Definition: printing.c:99
WORD nMaxPage
Definition: commdlg.h:474
HDC hDC
Definition: commdlg.h:469
DWORD Flags
Definition: commdlg.h:470
WORD nFromPage
Definition: commdlg.h:471
HGLOBAL hDevMode
Definition: commdlg.h:467
WORD nToPage
Definition: commdlg.h:472
WORD nMinPage
Definition: commdlg.h:473
HGLOBAL hDevNames
Definition: commdlg.h:468
HWND hwndOwner
Definition: commdlg.h:466
DWORD lStructSize
Definition: commdlg.h:465
int ret
#define LPTR
Definition: winbase.h:381
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define MM_TEXT
Definition: wingdi.h:873
#define DialogBoxParam
Definition: winuser.h:5776
#define IDABORT
Definition: winuser.h:835

Referenced by HandleCommandLine(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileSave()

BOOL DIALOG_FileSave ( VOID  )

Definition at line 457 of file dialog.c.

458{
459 if (Globals.szFileName[0] == 0)
460 {
461 return DIALOG_FileSaveAs();
462 }
463 else if (DoSaveFile())
464 {
466 return TRUE;
467 }
468 return FALSE;
469}
BOOL DIALOG_FileSaveAs(VOID)
Definition: dialog.c:532
static BOOL DoSaveFile(VOID)
Definition: dialog.c:250
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:79

Referenced by DoCloseFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileSaveAs()

BOOL DIALOG_FileSaveAs ( VOID  )

Definition at line 532 of file dialog.c.

533{
534 OPENFILENAME saveas;
536
537 ZeroMemory(&saveas, sizeof(saveas));
538
539 if (Globals.szFileName[0] == 0)
541 else
542 _tcscpy(szPath, Globals.szFileName);
543
544 saveas.lStructSize = sizeof(OPENFILENAME);
545 saveas.hwndOwner = Globals.hMainWnd;
546 saveas.hInstance = Globals.hInstance;
547 saveas.lpstrFilter = Globals.szFilter;
548 saveas.lpstrFile = szPath;
549 saveas.nMaxFile = _countof(szPath);
552 saveas.lpstrDefExt = szDefaultExt;
555
556 if (GetSaveFileName(&saveas))
557 {
558 /* HACK: Because in ROS, Save-As boxes don't check the validity
559 * of file names and thus, here, szPath can be invalid !! We only
560 * see its validity when we call DoSaveFile()... */
562 if (DoSaveFile())
563 {
566 return TRUE;
567 }
568 else
569 {
570 SetFileName(_T(""));
571 return FALSE;
572 }
573 }
574 else
575 {
576 return FALSE;
577 }
578}
static VOID SetFileName(PCONSOLE_CHILDFRM_WND Info, PWSTR pFileName)
Definition: console.c:180
static UINT_PTR CALLBACK DIALOG_FileSaveAs_Hook(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:473
#define OFN_OVERWRITEPROMPT
Definition: commdlg.h:116
#define GetSaveFileName
Definition: commdlg.h:666
#define OFN_ENABLEHOOK
Definition: commdlg.h:99
#define OFN_ENABLETEMPLATE
Definition: commdlg.h:102
OPENFILENAMEA OPENFILENAME
Definition: commdlg.h:657
#define DIALOG_ENCODING
Definition: notepad_res.h:14
LPCSTR lpTemplateName
Definition: commdlg.h:348
LPOFNHOOKPROC lpfnHook
Definition: commdlg.h:347

Referenced by DIALOG_FileSave(), and NOTEPAD_MenuCommand().

◆ DIALOG_GoTo()

VOID DIALOG_GoTo ( VOID  )

Definition at line 891 of file dialog.c.

892{
893 GOTO_DATA GotoData;
894 DWORD dwStart = 0, dwEnd = 0;
895 INT ich, cch = GetWindowTextLength(Globals.hEdit);
896
897 /* Get the current line number and the total line number */
898 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwStart, (LPARAM) &dwEnd);
899 GotoData.iLine = (UINT)SendMessage(Globals.hEdit, EM_LINEFROMCHAR, dwStart, 0) + 1;
900 GotoData.cLines = (UINT)SendMessage(Globals.hEdit, EM_GETLINECOUNT, 0, 0);
901
902 /* Ask the user for line number */
907 (LPARAM)&GotoData) != IDOK)
908 {
909 return; /* Canceled */
910 }
911
912 --GotoData.iLine; /* Make it zero-based */
913
914 /* Get ich (the target character index) from line number */
915 if (GotoData.iLine <= 0)
916 ich = 0;
917 else if (GotoData.iLine >= GotoData.cLines)
918 ich = cch;
919 else
920 ich = (INT)SendMessage(Globals.hEdit, EM_LINEINDEX, GotoData.iLine, 0);
921
922 /* EM_LINEINDEX can return -1 on failure */
923 if (ich < 0)
924 ich = 0;
925
926 /* Move the caret */
927 SendMessage(Globals.hEdit, EM_SETSEL, ich, ich);
928 SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
929}
static INT_PTR CALLBACK DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:849
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
unsigned int UINT
Definition: ndis.h:50
#define DIALOG_GOTO
Definition: notepad_res.h:17
#define INT
Definition: polytest.cpp:20
#define EM_SCROLLCARET
Definition: richedit.h:81
UINT iLine
Definition: dialog.c:843
UINT cLines
Definition: dialog.c:844
int32_t INT
Definition: typedefs.h:58
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_LINEFROMCHAR
Definition: winuser.h:2004
#define GetWindowTextLength
Definition: winuser.h:5811
#define EM_GETSEL
Definition: winuser.h:2000
#define EM_LINEINDEX
Definition: winuser.h:2005
#define EM_GETLINECOUNT
Definition: winuser.h:1995

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_HelpAboutNotepad()

VOID DIALOG_HelpAboutNotepad ( VOID  )

Definition at line 959 of file dialog.c.

960{
961 TCHAR szNotepad[MAX_STRING_LEN];
962 TCHAR szNotepadAuthors[MAX_STRING_LEN];
963
964 LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad));
965 LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, _countof(szNotepadAuthors));
966
967 ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors,
969}
#define STRING_NOTEPAD_AUTHORS
Definition: notepad_res.h:101
#define STRING_NOTEPAD
Definition: notepad_res.h:63
#define IDI_NPICON
Definition: notepad_res.h:19
#define ShellAbout
Definition: shellapi.h:692
#define LoadIcon
Definition: winuser.h:5825

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_HelpContents()

VOID DIALOG_HelpContents ( VOID  )

Definition at line 954 of file dialog.c.

955{
957}
static const TCHAR helpfile[]
Definition: dialog.c:19
#define WinHelp
Definition: winuser.h:5876
#define HELP_INDEX
Definition: winuser.h:2413

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

837{
839}
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:791
#define ReplaceText
Definition: commdlg.h:669

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_Search()

VOID DIALOG_Search ( VOID  )

Definition at line 818 of file dialog.c.

819{
821}
#define FindText
Definition: commdlg.h:663

Referenced by DIALOG_SearchNext(), and NOTEPAD_MenuCommand().

◆ DIALOG_SearchNext()

VOID DIALOG_SearchNext ( BOOL  bDown)

Definition at line 823 of file dialog.c.

824{
825 if (bDown)
826 Globals.find.Flags |= FR_DOWN;
827 else
828 Globals.find.Flags &= ~FR_DOWN;
829
830 if (Globals.find.lpstrFindWhat != NULL && *Globals.find.lpstrFindWhat)
832 else
834}
VOID DIALOG_Search(VOID)
Definition: dialog.c:818
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:132
#define FR_DOWN
Definition: commdlg.h:127

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_SelectFont()

VOID DIALOG_SelectFont ( VOID  )

Definition at line 766 of file dialog.c.

767{
769 LOGFONT lf = Globals.lfFont;
770
771 ZeroMemory( &cf, sizeof(cf) );
772 cf.lStructSize = sizeof(cf);
773 cf.hwndOwner = Globals.hMainWnd;
774 cf.lpLogFont = &lf;
776
777 if (ChooseFont(&cf))
778 {
779 HFONT currfont = Globals.hFont;
780
781 Globals.hFont = CreateFontIndirect(&lf);
782 Globals.lfFont = lf;
784 if (currfont != NULL)
785 DeleteObject(currfont);
786 }
787}
#define ChooseFont
Definition: commdlg.h:662
#define CF_INITTOLOGFONTSTRUCT
Definition: commdlg.h:66
#define CF_NOVERTFONTS
Definition: commdlg.h:86
#define CF_SCREENFONTS
Definition: commdlg.h:59
pKey DeleteObject()
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define CreateFontIndirect
Definition: wingdi.h:4444
#define WM_SETFONT
Definition: winuser.h:1653

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_StatusBarAlignParts()

VOID DIALOG_StatusBarAlignParts ( VOID  )

Definition at line 147 of file dialog.c.

148{
149 static const int defaultWidths[] = {120, 120, 120};
150 RECT rcStatusBar;
151 int parts[3];
152
153 GetClientRect(Globals.hStatusBar, &rcStatusBar);
154
155 parts[0] = rcStatusBar.right - (defaultWidths[1] + defaultWidths[2]);
156 parts[1] = rcStatusBar.right - defaultWidths[2];
157 parts[2] = -1; // the right edge of the status bar
158
159 parts[0] = max(parts[0], defaultWidths[0]);
160 parts[1] = max(parts[1], defaultWidths[0] + defaultWidths[1]);
161
163}
std::map< E_STRING, PART_TEST > parts
Definition: LocaleTests.cpp:67
#define SB_SETPARTS
Definition: commctrl.h:1959
LONG right
Definition: windef.h:308
#define max(a, b)
Definition: svc.c:63
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by NOTEPAD_WndProc().

◆ DIALOG_StatusBarUpdateCaretPos()

VOID DIALOG_StatusBarUpdateCaretPos ( VOID  )

Definition at line 931 of file dialog.c.

932{
933 int line, ich, col;
935 DWORD dwStart, dwSize;
936
937 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize);
938 line = (int)SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0);
939 ich = (int)SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);
940
941 /* EM_LINEINDEX can return -1 on failure */
942 col = ((ich < 0) ? 0 : (dwStart - ich));
943
944 StringCchPrintf(buff, _countof(buff), Globals.szStatusBarLineCol, line + 1, col + 1);
946}
#define SBPART_CURPOS
Definition: dialog.c:25
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static unsigned char buff[32768]
Definition: fatten.c:17
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define SB_SETTEXT
Definition: commctrl.h:1954
#define StringCchPrintf
Definition: strsafe.h:517
Definition: parser.c:49

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

◆ DIALOG_StringMsgBox()

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

Definition at line 193 of file dialog.c.

194{
195 TCHAR szMessage[MAX_STRING_LEN];
196 TCHAR szResource[MAX_STRING_LEN];
197
198 /* Load and format szMessage */
199 LoadString(Globals.hInstance, formatId, szResource, _countof(szResource));
200 StringCchPrintf(szMessage, _countof(szMessage), szResource, szString);
201
202 /* Load szCaption */
204 LoadString(Globals.hInstance, STRING_ERROR, szResource, _countof(szResource));
205 else
206 LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, _countof(szResource));
207
208 /* Display Modal Dialog */
209 // if (hParent == NULL)
210 // hParent = Globals.hMainWnd;
211 return MessageBox(hParent, szMessage, szResource, dwFlags);
212}
#define STRING_ERROR
Definition: notepad_res.h:64
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define MB_ICONMASK
Definition: winuser.h:822
#define MB_ICONEXCLAMATION
Definition: winuser.h:788
#define MessageBox
Definition: winuser.h:5834

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

◆ DIALOG_TimeDate()

VOID DIALOG_TimeDate ( VOID  )

◆ DIALOG_ViewStatusBar()

VOID DIALOG_ViewStatusBar ( VOID  )

Definition at line 948 of file dialog.c.

949{
950 Globals.bShowStatusBar = !Globals.bShowStatusBar;
952}

Referenced by 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 311 of file dialog.c.

312{
313 int nResult;
314
315 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
316 {
317 /* prompt user to save changes */
318 nResult = AlertFileNotSaved(Globals.szFileName);
319 switch (nResult)
320 {
321 case IDYES:
322 if(!DIALOG_FileSave())
323 return FALSE;
324 break;
325
326 case IDNO:
327 break;
328
329 case IDCANCEL:
330 default:
331 return FALSE;
332 }
333 }
334
337
338 return TRUE;
339}
static const TCHAR empty_str[]
Definition: dialog.c:20
static int AlertFileNotSaved(LPCTSTR szFileName)
Definition: dialog.c:219
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:457
#define EM_GETMODIFY
Definition: winuser.h:1997
#define IDNO
Definition: winuser.h:839
#define IDYES
Definition: winuser.h:838

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

◆ DoCreateEditWindow()

VOID DoCreateEditWindow ( VOID  )

Definition at line 665 of file dialog.c.

666{
667 DWORD dwStyle;
668 int iSize;
669 LPTSTR pTemp = NULL;
670 BOOL bModified = FALSE;
671
672 iSize = 0;
673
674 /* If the edit control already exists, try to save its content */
675 if (Globals.hEdit != NULL)
676 {
677 /* number of chars currently written into the editor. */
678 iSize = GetWindowTextLength(Globals.hEdit);
679 if (iSize)
680 {
681 /* Allocates temporary buffer. */
682 pTemp = HeapAlloc(GetProcessHeap(), 0, (iSize + 1) * sizeof(TCHAR));
683 if (!pTemp)
684 {
686 return;
687 }
688
689 /* Recover the text into the control. */
690 GetWindowText(Globals.hEdit, pTemp, iSize + 1);
691
692 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
693 bModified = TRUE;
694 }
695
696 /* Restore original window procedure */
698
699 /* Destroy the edit control */
700 DestroyWindow(Globals.hEdit);
701 }
702
703 /* Update wrap status into the main menu and recover style flags */
704 dwStyle = (Globals.bWrapLongLines ? EDIT_STYLE_WRAP : EDIT_STYLE);
705
706 /* Create the new edit control */
709 NULL,
710 dwStyle,
716 NULL,
718 NULL);
719 if (Globals.hEdit == NULL)
720 {
721 if (pTemp)
722 {
723 HeapFree(GetProcessHeap(), 0, pTemp);
724 }
725
727 return;
728 }
729
731 SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0);
732
733 /* If some text was previously saved, restore it. */
734 if (iSize != 0)
735 {
736 SetWindowText(Globals.hEdit, pTemp);
737 HeapFree(GetProcessHeap(), 0, pTemp);
738
739 if (bModified)
741 }
742
743 /* Sub-class a new window callback for row/column detection. */
744 Globals.EditProc = (WNDPROC)SetWindowLongPtr(Globals.hEdit,
747
748 /* Finally shows new edit control and set focus into it. */
749 ShowWindow(Globals.hEdit, SW_SHOW);
750 SetFocus(Globals.hEdit);
751
752 /* Re-arrange controls */
754}
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:294
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define EDIT_STYLE
Definition: notepad.h:33
#define EDIT_STYLE_WRAP
Definition: notepad.h:32
#define EDIT_CLASS
Definition: notepad.h:34
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
#define CreateWindowEx
Definition: winuser.h:5767
#define EM_LIMITTEXT
Definition: winuser.h:2003
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_SIZE
Definition: winuser.h:1614
HWND WINAPI SetFocus(_In_opt_ HWND)
#define GetWindowText
Definition: winuser.h:5810
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SW_SHOW
Definition: winuser.h:778
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
BOOL WINAPI DestroyWindow(_In_ HWND)
#define EM_SETMODIFY
Definition: winuser.h:2016
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by DIALOG_EditWrap(), and NOTEPAD_WndProc().

◆ DoOpenFile()

VOID DoOpenFile ( LPCTSTR  szFileName)

Definition at line 341 of file dialog.c.

342{
344 TCHAR log[5];
345 HLOCAL hLocal;
346
347 /* Close any files and prompt to save changes */
348 if (!DoCloseFile())
349 return;
350
352 SetWindowText(Globals.hEdit, NULL);
353
357 {
359 goto done;
360 }
361
362 /* To make loading file quicker, we use the internal handle of EDIT control */
363 hLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0);
364 if (!ReadText(hFile, &hLocal, &Globals.encFile, &Globals.iEoln))
365 {
367 goto done;
368 }
369 SendMessageW(Globals.hEdit, EM_SETHANDLE, (WPARAM)hLocal, 0);
370 /* No need of EM_SETMODIFY and EM_EMPTYUNDOBUFFER here. EM_SETHANDLE does instead. */
371
372 SetFocus(Globals.hEdit);
373
374 /* If the file starts with .LOG, add a time/date at the end and set cursor after
375 * See http://web.archive.org/web/20090627165105/http://support.microsoft.com/kb/260563
376 */
377 if (GetWindowText(Globals.hEdit, log, _countof(log)) && !_tcscmp(log, _T(".LOG")))
378 {
379 static const TCHAR lf[] = _T("\r\n");
384 }
385
386 SetFileName(szFileName);
390
391done:
395}
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:615
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define _tcscmp
Definition: tchar.h:1424
#define OPEN_ALWAYS
Definition: disk.h:70
_In_ HANDLE hFile
Definition: mswsock.h:90
BOOL ReadText(HANDLE hFile, HLOCAL *phLocal, ENCODING *pencFile, EOLN *piEoln)
Definition: text.c:153
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define log(outFile, fmt,...)
Definition: util.h:15
#define CreateFile
Definition: winbase.h:3749
HANDLE HLOCAL
Definition: windef.h:244
#define EM_GETHANDLE
Definition: winuser.h:1992
#define EM_SETHANDLE
Definition: winuser.h:2012

Referenced by DIALOG_FileOpen().

◆ DoShowHideStatusBar()

VOID DoShowHideStatusBar ( VOID  )

Definition at line 631 of file dialog.c.

632{
633 /* Check if status bar object already exists. */
634 if (Globals.bShowStatusBar && Globals.hStatusBar == NULL)
635 {
636 /* Try to create the status bar */
638 NULL,
641
642 if (Globals.hStatusBar == NULL)
643 {
645 return;
646 }
647
648 /* Load the string for formatting column/row text output */
650 }
651
652 /* Update layout of controls */
654
655 if (Globals.hStatusBar == NULL)
656 return;
657
658 /* Update visibility of status bar */
659 ShowWindow(Globals.hStatusBar, (Globals.bShowStatusBar ? SW_SHOWNOACTIVATE : SW_HIDE));
660
661 /* Update status bar contents */
663}
#define CMD_STATUSBAR_WND_ID
Definition: notepad_res.h:54
#define STRING_LINE_COLUMN
Definition: notepad_res.h:89
#define WS_CHILD
Definition: pedump.c:617
#define CreateStatusWindow
Definition: commctrl.h:1938
#define CCS_BOTTOM
Definition: commctrl.h:2249
#define SBARS_SIZEGRIP
Definition: commctrl.h:1928
#define SW_HIDE
Definition: winuser.h:771
#define SW_SHOWNOACTIVATE
Definition: winuser.h:777

Referenced by DIALOG_EditWrap(), DIALOG_ViewStatusBar(), and NOTEPAD_WndProc().

◆ FileExists()

BOOL FileExists ( LPCTSTR  szFilename)

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

Definition at line 235 of file dialog.c.

236{
237 return GetFileAttributes(szFilename) != INVALID_FILE_ATTRIBUTES;
238}
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GetFileAttributes
Definition: winbase.h:3815

Referenced by DIALOG_FileOpen(), and HandleCommandLine().

◆ HasFileExtension()

BOOL HasFileExtension ( LPCTSTR  szFilename)

Definition at line 240 of file dialog.c.

241{
242 LPCTSTR s;
243
244 s = _tcsrchr(szFilename, _T('\\'));
245 if (s)
246 szFilename = s;
247 return _tcsrchr(szFilename, _T('.')) != NULL;
248}
GLdouble s
Definition: gl.h:2039
#define _tcsrchr
Definition: utility.h:116
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Referenced by HandleCommandLine().

◆ ShowLastError()

VOID ShowLastError ( VOID  )

Definition at line 45 of file dialog.c.

46{
48 if (error != NO_ERROR)
49 {
50 LPTSTR lpMsgBuf = NULL;
52 TCHAR szFallback[42], *pszMessage = szFallback;
53
55
57 NULL,
58 error,
59 0,
60 (LPTSTR) &lpMsgBuf,
61 0,
62 NULL);
63
64 if (lpMsgBuf)
65 pszMessage = lpMsgBuf;
66 else
67 wsprintfW(szFallback, L"%d", error);
68
70 LocalFree(lpMsgBuf);
71 }
72}
#define NO_ERROR
Definition: dderror.h:5
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define error(str)
Definition: mkdosfs.c:1605
#define L(x)
Definition: ntvdm.h:50
#define FormatMessage
Definition: winbase.h:3795
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:423
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:419
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
#define MB_ICONERROR
Definition: winuser.h:790
#define MB_OK
Definition: winuser.h:793

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

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

80{
81 TCHAR szCaption[MAX_STRING_LEN];
82 TCHAR szNotepad[MAX_STRING_LEN];
83 TCHAR szFilename[MAX_STRING_LEN];
84 BOOL isModified;
85
86 if (clearModifyAlert)
87 {
88 /* When a file is being opened or created, there is no need to have
89 * the edited flag shown when the file has not been edited yet. */
90 isModified = FALSE;
91 }
92 else
93 {
94 /* Check whether the user has modified the file or not. If we are
95 * in the same state as before, don't change the caption. */
96 isModified = !!SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0);
97 if (isModified == Globals.bWasModified)
98 return;
99 }
100
101 /* Remember the state for later calls */
102 Globals.bWasModified = isModified;
103
104 /* Load the name of the application */
105 LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad));
106
107 /* Determine if the file has been saved or if this is a new file */
108 if (Globals.szFileTitle[0] != 0)
109 StringCchCopy(szFilename, _countof(szFilename), Globals.szFileTitle);
110 else
111 LoadString(Globals.hInstance, STRING_UNTITLED, szFilename, _countof(szFilename));
112
113 /* Update the window caption based upon whether the user has modified the file or not */
114 StringCbPrintf(szCaption, sizeof(szCaption), _T("%s%s - %s"),
115 (isModified ? _T("*") : _T("")), szFilename, szNotepad);
116
117 SetWindowText(Globals.hMainWnd, szCaption);
118}
#define STRING_UNTITLED
Definition: notepad_res.h:67
#define StringCchCopy
Definition: strsafe.h:139
#define StringCbPrintf
Definition: strsafe.h:544

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

◆ WaitCursor()

VOID WaitCursor ( BOOL  bBegin)

Definition at line 120 of file dialog.c.

121{
122 static HCURSOR s_hWaitCursor = NULL;
123 static HCURSOR s_hOldCursor = NULL;
124 static INT s_nLock = 0;
125
126 if (bBegin)
127 {
128 if (s_nLock++ == 0)
129 {
130 if (s_hWaitCursor == NULL)
131 s_hWaitCursor = LoadCursor(NULL, IDC_WAIT);
132 s_hOldCursor = SetCursor(s_hWaitCursor);
133 }
134 else
135 {
136 SetCursor(s_hWaitCursor);
137 }
138 }
139 else
140 {
141 if (--s_nLock == 0)
142 SetCursor(s_hOldCursor);
143 }
144}
HICON HCURSOR
Definition: windef.h:299
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define LoadCursor
Definition: winuser.h:5824
#define IDC_WAIT
Definition: winuser.h:689

Referenced by _tWinMain(), FileChildWindow::activate_entry(), StartMenu::AddEntries(), RecentStartMenu::AddEntries(), QuickLaunchBar::AddShortcuts(), DIALOG_FileNew(), DIALOG_FileNewWindow(), DoOpenFile(), DoSaveFile(), Favorites::import_IE_favorites(), ShellBrowser::InsertSubitems(), ShellBrowser::jump_to_pidl(), NOTEPAD_WndProc(), FindProgramDlg::Notify(), Entry::read_tree(), FileChildWindow::refresh(), FindProgramDlg::Refresh(), and FileChildWindow::set_curdir().