ReactOS 0.4.15-dev-7788-g1ad9096
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.

Classes

struct  tagGOTO_DATA
 

Macros

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

Typedefs

typedef HWND(WINAPIFINDPROC) (LPFINDREPLACE lpfr)
 
typedef struct tagGOTO_DATA GOTO_DATA
 
typedef struct tagGOTO_DATAPGOTO_DATA
 

Functions

LRESULT CALLBACK EDIT_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
VOID ShowLastError (VOID)
 
void UpdateWindowCaption (BOOL clearModifyAlert)
 
VOID WaitCursor (BOOL bBegin)
 
VOID DIALOG_StatusBarAlignParts (VOID)
 
static VOID DIALOG_StatusBarUpdateLineEndings (VOID)
 
static VOID DIALOG_StatusBarUpdateEncoding (VOID)
 
static VOID DIALOG_StatusBarUpdateAll (VOID)
 
int DIALOG_StringMsgBox (HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
 
static void AlertFileNotFound (LPCTSTR szFileName)
 
static int AlertFileNotSaved (LPCTSTR szFileName)
 
BOOL FileExists (LPCTSTR szFilename)
 
BOOL HasFileExtension (LPCTSTR szFilename)
 
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_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 DoShowHideStatusBar (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 (BOOL bDown)
 
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)
 

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

◆ SBPART_ENCODING

#define SBPART_ENCODING   2

Definition at line 27 of file dialog.c.

◆ SBPART_EOLN

#define SBPART_EOLN   1

Definition at line 26 of file dialog.c.

Typedef Documentation

◆ FINDPROC

typedef HWND(WINAPI * FINDPROC) (LPFINDREPLACE lpfr)

Definition at line 778 of file dialog.c.

◆ GOTO_DATA

◆ PGOTO_DATA

Function Documentation

◆ AlertFileNotFound()

static void AlertFileNotFound ( LPCTSTR  szFileName)
static

Definition at line 208 of file dialog.c.

209{
211}
int DIALOG_StringMsgBox(HWND hParent, int formatId, LPCTSTR szString, DWORD dwFlags)
Definition: dialog.c:187
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
#define STRING_NOTFOUND
Definition: notepad_res.h:75
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_OK
Definition: winuser.h:790

Referenced by DIALOG_FileOpen().

◆ AlertFileNotSaved()

static int AlertFileNotSaved ( LPCTSTR  szFileName)
static

Definition at line 213 of file dialog.c.

214{
215 TCHAR szUntitled[MAX_STRING_LEN];
216
217 LoadString(Globals.hInstance, STRING_UNTITLED, szUntitled, _countof(szUntitled));
218
220 szFileName[0] ? szFileName : szUntitled,
222}
#define MAX_STRING_LEN
Definition: precomp.h:36
#define STRING_NOTSAVED
Definition: notepad_res.h:73
#define STRING_UNTITLED
Definition: notepad_res.h:67
#define _countof(array)
Definition: sndvol32.h:68
HINSTANCE hInstance
Definition: precomp.h:43
#define LoadString
Definition: winuser.h:5819
#define MB_ICONQUESTION
Definition: winuser.h:789
#define MB_YESNOCANCEL
Definition: winuser.h:818
char TCHAR
Definition: xmlstorage.h:189

Referenced by DoCloseFile().

◆ DIALOG_EditCopy()

VOID DIALOG_EditCopy ( VOID  )

Definition at line 584 of file dialog.c.

585{
586 SendMessage(Globals.hEdit, WM_COPY, 0, 0);
587}
#define SendMessage
Definition: winuser.h:5843
#define WM_COPY
Definition: winuser.h:1862

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditCut()

VOID DIALOG_EditCut ( VOID  )

Definition at line 579 of file dialog.c.

580{
581 SendMessage(Globals.hEdit, WM_CUT, 0, 0);
582}
#define WM_CUT
Definition: winuser.h:1861

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditDelete()

VOID DIALOG_EditDelete ( VOID  )

Definition at line 594 of file dialog.c.

595{
596 SendMessage(Globals.hEdit, WM_CLEAR, 0, 0);
597}
#define WM_CLEAR
Definition: winuser.h:1864

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditPaste()

VOID DIALOG_EditPaste ( VOID  )

Definition at line 589 of file dialog.c.

590{
591 SendMessage(Globals.hEdit, WM_PASTE, 0, 0);
592}
#define WM_PASTE
Definition: winuser.h:1863

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditSelectAll()

VOID DIALOG_EditSelectAll ( VOID  )

Definition at line 599 of file dialog.c.

600{
601 SendMessage(Globals.hEdit, EM_SETSEL, 0, -1);
602}
#define EM_SETSEL
Definition: winuser.h:2018

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditTimeDate()

VOID DIALOG_EditTimeDate ( VOID  )

Definition at line 604 of file dialog.c.

605{
606 SYSTEMTIME st;
607 TCHAR szDate[MAX_STRING_LEN];
608 TCHAR szText[MAX_STRING_LEN * 2 + 2];
609
610 GetLocalTime(&st);
611
613 _tcscpy(szText, szDate);
614 _tcscat(szText, _T(" "));
616 _tcscat(szText, szDate);
617 SendMessage(Globals.hEdit, EM_REPLACESEL, TRUE, (LPARAM)szText);
618}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
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
LONG_PTR LPARAM
Definition: windef.h:208
#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:2006

Referenced by DoOpenFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_EditUndo()

VOID DIALOG_EditUndo ( VOID  )

Definition at line 574 of file dialog.c.

575{
576 SendMessage(Globals.hEdit, EM_UNDO, 0, 0);
577}
#define EM_UNDO
Definition: winuser.h:2021

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_EditWrap()

VOID DIALOG_EditWrap ( VOID  )

Definition at line 745 of file dialog.c.

746{
747 Globals.bWrapLongLines = !Globals.bWrapLongLines;
748
750
753}
VOID DoShowHideStatusBar(VOID)
Definition: dialog.c:620
VOID DoCreateEditWindow(VOID)
Definition: dialog.c:654
#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 569 of file dialog.c.

570{
572}
#define WM_CLOSE
Definition: winuser.h:1621
#define PostMessage
Definition: winuser.h:5832

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileNew()

VOID DIALOG_FileNew ( VOID  )

Definition at line 386 of file dialog.c.

387{
388 /* Close any files and prompt to save changes */
389 if (!DoCloseFile())
390 return;
391
393
394 SetWindowText(Globals.hEdit, NULL);
396 Globals.iEoln = EOLN_CRLF;
397 Globals.encFile = ENCODING_DEFAULT;
398
401
403}
VOID WaitCursor(BOOL bBegin)
Definition: dialog.c:114
static VOID DIALOG_StatusBarUpdateAll(VOID)
Definition: dialog.c:180
BOOL DoCloseFile(VOID)
Definition: dialog.c:301
VOID NOTEPAD_EnableSearchMenu()
Definition: main.c:20
#define FALSE
Definition: types.h:117
#define ENCODING_DEFAULT
Definition: notepad.h:49
@ EOLN_CRLF
Definition: notepad.h:53
#define EM_EMPTYUNDOBUFFER
Definition: winuser.h:1985
#define SetWindowText
Definition: winuser.h:5857

Referenced by NOTEPAD_MenuCommand(), and NOTEPAD_WndProc().

◆ DIALOG_FileNewWindow()

VOID DIALOG_FileNewWindow ( VOID  )

Definition at line 405 of file dialog.c.

406{
407 TCHAR pszNotepadExe[MAX_PATH];
408
410
411 GetModuleFileName(NULL, pszNotepadExe, _countof(pszNotepadExe));
412 ShellExecute(NULL, NULL, pszNotepadExe, NULL, NULL, SW_SHOWNORMAL);
413
415}
#define MAX_PATH
Definition: compat.h:34
#define ShellExecute
Definition: shellapi.h:690
#define GetModuleFileName
Definition: winbase.h:3766
#define SW_SHOWNORMAL
Definition: winuser.h:770

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_FileOpen()

VOID DIALOG_FileOpen ( VOID  )

Definition at line 417 of file dialog.c.

418{
419 OPENFILENAME openfilename;
421
422 ZeroMemory(&openfilename, sizeof(openfilename));
423
424 if (Globals.szFileName[0] == 0)
426 else
427 _tcscpy(szPath, Globals.szFileName);
428
429 openfilename.lStructSize = sizeof(openfilename);
430 openfilename.hwndOwner = Globals.hMainWnd;
431 openfilename.hInstance = Globals.hInstance;
432 openfilename.lpstrFilter = Globals.szFilter;
433 openfilename.lpstrFile = szPath;
434 openfilename.nMaxFile = _countof(szPath);
436 openfilename.lpstrDefExt = szDefaultExt;
437
438 if (GetOpenFileName(&openfilename)) {
439 if (FileExists(openfilename.lpstrFile))
440 DoOpenFile(openfilename.lpstrFile);
441 else
442 AlertFileNotFound(openfilename.lpstrFile);
443 }
444}
static void AlertFileNotFound(LPCTSTR szFileName)
Definition: dialog.c:208
static const TCHAR txt_files[]
Definition: dialog.c:22
BOOL FileExists(LPCTSTR szFilename)
Definition: dialog.c:229
static const TCHAR szDefaultExt[]
Definition: dialog.c:21
VOID DoOpenFile(LPCTSTR szFileName)
Definition: dialog.c:331
#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
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_FileSave()

BOOL DIALOG_FileSave ( VOID  )

Definition at line 446 of file dialog.c.

447{
448 if (Globals.szFileName[0] == 0)
449 {
450 return DIALOG_FileSaveAs();
451 }
452 else if (DoSaveFile())
453 {
455 return TRUE;
456 }
457 return FALSE;
458}
BOOL DIALOG_FileSaveAs(VOID)
Definition: dialog.c:521
static BOOL DoSaveFile(VOID)
Definition: dialog.c:244
void UpdateWindowCaption(BOOL clearModifyAlert)
Definition: dialog.c:73

Referenced by DoCloseFile(), and NOTEPAD_MenuCommand().

◆ DIALOG_FileSaveAs()

BOOL DIALOG_FileSaveAs ( VOID  )

Definition at line 521 of file dialog.c.

522{
523 OPENFILENAME saveas;
525
526 ZeroMemory(&saveas, sizeof(saveas));
527
528 if (Globals.szFileName[0] == 0)
530 else
531 _tcscpy(szPath, Globals.szFileName);
532
533 saveas.lStructSize = sizeof(OPENFILENAME);
534 saveas.hwndOwner = Globals.hMainWnd;
535 saveas.hInstance = Globals.hInstance;
536 saveas.lpstrFilter = Globals.szFilter;
537 saveas.lpstrFile = szPath;
538 saveas.nMaxFile = _countof(szPath);
541 saveas.lpstrDefExt = szDefaultExt;
544
545 if (GetSaveFileName(&saveas))
546 {
547 /* HACK: Because in ROS, Save-As boxes don't check the validity
548 * of file names and thus, here, szPath can be invalid !! We only
549 * see its validity when we call DoSaveFile()... */
551 if (DoSaveFile())
552 {
555 return TRUE;
556 }
557 else
558 {
559 SetFileName(_T(""));
560 return FALSE;
561 }
562 }
563 else
564 {
565 return FALSE;
566 }
567}
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:462
#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
#define MAKEINTRESOURCE
Definition: winuser.h:591

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

463{
464 TCHAR szText[128];
465 HWND hCombo;
466
468
469 switch(msg)
470 {
471 case WM_INITDIALOG:
472 hCombo = GetDlgItem(hDlg, ID_ENCODING);
473
475 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
476
478 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
479
481 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
482
484 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
485
487 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
488
489 SendMessage(hCombo, CB_SETCURSEL, Globals.encFile, 0);
490
491 hCombo = GetDlgItem(hDlg, ID_EOLN);
492
494 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
495
496 LoadString(Globals.hInstance, STRING_LF, szText, _countof(szText));
497 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
498
499 LoadString(Globals.hInstance, STRING_CR, szText, _countof(szText));
500 SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM) szText);
501
502 SendMessage(hCombo, CB_SETCURSEL, Globals.iEoln, 0);
503 break;
504
505 case WM_NOTIFY:
506 if (((NMHDR *) lParam)->code == CDN_FILEOK)
507 {
508 hCombo = GetDlgItem(hDlg, ID_ENCODING);
509 if (hCombo)
510 Globals.encFile = (ENCODING) SendMessage(hCombo, CB_GETCURSEL, 0, 0);
511
512 hCombo = GetDlgItem(hDlg, ID_EOLN);
513 if (hCombo)
514 Globals.iEoln = (EOLN)SendMessage(hCombo, CB_GETCURSEL, 0, 0);
515 }
516 break;
517 }
518 return 0;
519}
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define CDN_FILEOK
Definition: commdlg.h:38
ENCODING
Definition: more.c:492
EOLN
Definition: notepad.h:52
#define ID_ENCODING
Definition: notepad_res.h:15
#define ID_EOLN
Definition: notepad_res.h:16
#define STRING_CR
Definition: notepad_res.h:87
#define STRING_UTF8
Definition: notepad_res.h:82
#define STRING_LF
Definition: notepad_res.h:86
#define STRING_ANSI
Definition: notepad_res.h:79
#define STRING_UTF8_BOM
Definition: notepad_res.h:83
#define STRING_UNICODE_BE
Definition: notepad_res.h:81
#define STRING_UNICODE
Definition: notepad_res.h:80
#define STRING_CRLF
Definition: notepad_res.h:85
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define WM_NOTIFY
Definition: richedit.h:61
Definition: inflate.c:139
#define CB_SETCURSEL
Definition: winuser.h:1961
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define CB_ADDSTRING
Definition: winuser.h:1936
#define CB_GETCURSEL
Definition: winuser.h:1943

Referenced by DIALOG_FileSaveAs().

◆ DIALOG_GoTo()

VOID DIALOG_GoTo ( VOID  )

Definition at line 880 of file dialog.c.

881{
882 GOTO_DATA GotoData;
883 DWORD dwStart = 0, dwEnd = 0;
884 INT ich, cch = GetWindowTextLength(Globals.hEdit);
885
886 /* Get the current line number and the total line number */
887 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM) &dwStart, (LPARAM) &dwEnd);
888 GotoData.iLine = (UINT)SendMessage(Globals.hEdit, EM_LINEFROMCHAR, dwStart, 0) + 1;
889 GotoData.cLines = (UINT)SendMessage(Globals.hEdit, EM_GETLINECOUNT, 0, 0);
890
891 /* Ask the user for line number */
896 (LPARAM)&GotoData) != IDOK)
897 {
898 return; /* Canceled */
899 }
900
901 --GotoData.iLine; /* Make it zero-based */
902
903 /* Get ich (the target character index) from line number */
904 if (GotoData.iLine <= 0)
905 ich = 0;
906 else if (GotoData.iLine >= GotoData.cLines)
907 ich = cch;
908 else
909 ich = (INT)SendMessage(Globals.hEdit, EM_LINEINDEX, GotoData.iLine, 0);
910
911 /* EM_LINEINDEX can return -1 on failure */
912 if (ich < 0)
913 ich = 0;
914
915 /* Move the caret */
916 SendMessage(Globals.hEdit, EM_SETSEL, ich, ich);
917 SendMessage(Globals.hEdit, EM_SCROLLCARET, 0, 0);
918}
static INT_PTR CALLBACK DIALOG_GoTo_DialogProc(HWND hwndDialog, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:838
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:832
UINT cLines
Definition: dialog.c:833
int32_t INT
Definition: typedefs.h:58
UINT_PTR WPARAM
Definition: windef.h:207
#define EM_LINEFROMCHAR
Definition: winuser.h:2001
#define GetWindowTextLength
Definition: winuser.h:5799
#define EM_GETSEL
Definition: winuser.h:1997
#define DialogBoxParam
Definition: winuser.h:5764
#define EM_LINEINDEX
Definition: winuser.h:2002
#define IDOK
Definition: winuser.h:830
#define EM_GETLINECOUNT
Definition: winuser.h:1992

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

839{
840 static PGOTO_DATA s_pGotoData;
841
842 switch (uMsg)
843 {
844 case WM_INITDIALOG:
845 s_pGotoData = (PGOTO_DATA)lParam;
846 SetDlgItemInt(hwndDialog, ID_LINENUMBER, s_pGotoData->iLine, FALSE);
847 return TRUE; /* Set focus */
848
849 case WM_COMMAND:
850 {
851 if (LOWORD(wParam) == IDOK)
852 {
854 if (iLine <= 0 || s_pGotoData->cLines < iLine) /* Out of range */
855 {
856 /* Show error message */
857 WCHAR title[128], text[256];
860 MessageBoxW(hwndDialog, text, title, MB_OK);
861
862 SendDlgItemMessageW(hwndDialog, ID_LINENUMBER, EM_SETSEL, 0, -1);
863 SetFocus(GetDlgItem(hwndDialog, ID_LINENUMBER));
864 break;
865 }
866 s_pGotoData->iLine = iLine;
867 EndDialog(hwndDialog, IDOK);
868 }
869 else if (LOWORD(wParam) == IDCANCEL)
870 {
871 EndDialog(hwndDialog, IDCANCEL);
872 }
873 break;
874 }
875 }
876
877 return 0;
878}
struct tagGOTO_DATA * PGOTO_DATA
const WCHAR * text
Definition: package.c:1799
int iLine
Definition: hpp.c:35
#define ID_LINENUMBER
Definition: notepad_res.h:18
#define STRING_LINE_NUMBER_OUT_OF_RANGE
Definition: notepad_res.h:92
#define STRING_NOTEPAD
Definition: notepad_res.h:63
#define LOWORD(l)
Definition: pedump.c:82
static char title[]
Definition: ps.c:92
#define IDCANCEL
Definition: winuser.h:831
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define WM_COMMAND
Definition: winuser.h:1740
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
HWND WINAPI SetFocus(_In_opt_ HWND)
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DIALOG_GoTo().

◆ DIALOG_HelpAboutNotepad()

VOID DIALOG_HelpAboutNotepad ( VOID  )

Definition at line 948 of file dialog.c.

949{
950 TCHAR szNotepad[MAX_STRING_LEN];
951 TCHAR szNotepadAuthors[MAX_STRING_LEN];
952
953 LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, _countof(szNotepad));
954 LoadString(Globals.hInstance, STRING_NOTEPAD_AUTHORS, szNotepadAuthors, _countof(szNotepadAuthors));
955
956 ShellAbout(Globals.hMainWnd, szNotepad, szNotepadAuthors,
958}
#define STRING_NOTEPAD_AUTHORS
Definition: notepad_res.h:101
#define IDI_NPICON
Definition: notepad_res.h:19
#define ShellAbout
Definition: shellapi.h:689
#define LoadIcon
Definition: winuser.h:5813

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_HelpContents()

VOID DIALOG_HelpContents ( VOID  )

Definition at line 943 of file dialog.c.

944{
946}
static const TCHAR helpfile[]
Definition: dialog.c:19
#define WinHelp
Definition: winuser.h:5864
#define HELP_INDEX
Definition: winuser.h:2410

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_Replace()

VOID DIALOG_Replace ( VOID  )

Definition at line 825 of file dialog.c.

826{
828}
static VOID DIALOG_SearchDialog(FINDPROC pfnProc)
Definition: dialog.c:780
#define ReplaceText
Definition: commdlg.h:669

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_Search()

VOID DIALOG_Search ( VOID  )

Definition at line 807 of file dialog.c.

808{
810}
#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 780 of file dialog.c.

781{
782 if (Globals.hFindReplaceDlg != NULL)
783 {
784 SetFocus(Globals.hFindReplaceDlg);
785 return;
786 }
787
788 if (!Globals.find.lpstrFindWhat)
789 {
790 ZeroMemory(&Globals.find, sizeof(Globals.find));
791 Globals.find.lStructSize = sizeof(Globals.find);
792 Globals.find.hwndOwner = Globals.hMainWnd;
793 Globals.find.lpstrFindWhat = Globals.szFindText;
794 Globals.find.wFindWhatLen = _countof(Globals.szFindText);
795 Globals.find.lpstrReplaceWith = Globals.szReplaceText;
796 Globals.find.wReplaceWithLen = _countof(Globals.szReplaceText);
797 Globals.find.Flags = FR_DOWN;
798 }
799
800 /* We only need to create the modal FindReplace dialog which will */
801 /* notify us of incoming events using hMainWnd Window Messages */
802
803 Globals.hFindReplaceDlg = pfnProc(&Globals.find);
804 assert(Globals.hFindReplaceDlg != NULL);
805}
#define FR_DOWN
Definition: commdlg.h:127
#define assert(x)
Definition: debug.h:53

Referenced by DIALOG_Replace(), and DIALOG_Search().

◆ DIALOG_SearchNext()

VOID DIALOG_SearchNext ( BOOL  bDown)

Definition at line 812 of file dialog.c.

813{
814 if (bDown)
815 Globals.find.Flags |= FR_DOWN;
816 else
817 Globals.find.Flags &= ~FR_DOWN;
818
819 if (Globals.find.lpstrFindWhat != NULL)
821 else
823}
VOID DIALOG_Search(VOID)
Definition: dialog.c:807
BOOL NOTEPAD_FindNext(FINDREPLACE *pFindReplace, BOOL bReplace, BOOL bShowAlert)
Definition: main.c:132

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_SelectFont()

VOID DIALOG_SelectFont ( VOID  )

Definition at line 755 of file dialog.c.

756{
758 LOGFONT lf = Globals.lfFont;
759
760 ZeroMemory( &cf, sizeof(cf) );
761 cf.lStructSize = sizeof(cf);
762 cf.hwndOwner = Globals.hMainWnd;
763 cf.lpLogFont = &lf;
765
766 if (ChooseFont(&cf))
767 {
768 HFONT currfont = Globals.hFont;
769
770 Globals.hFont = CreateFontIndirect(&lf);
771 Globals.lfFont = lf;
773 if (currfont != NULL)
774 DeleteObject(currfont);
775 }
776}
#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:1650

Referenced by NOTEPAD_MenuCommand().

◆ DIALOG_StatusBarAlignParts()

VOID DIALOG_StatusBarAlignParts ( VOID  )

Definition at line 141 of file dialog.c.

142{
143 static const int defaultWidths[] = {120, 120, 120};
144 RECT rcStatusBar;
145 int parts[3];
146
147 GetClientRect(Globals.hStatusBar, &rcStatusBar);
148
149 parts[0] = rcStatusBar.right - (defaultWidths[1] + defaultWidths[2]);
150 parts[1] = rcStatusBar.right - defaultWidths[2];
151 parts[2] = -1; // the right edge of the status bar
152
153 parts[0] = max(parts[0], defaultWidths[0]);
154 parts[1] = max(parts[1], defaultWidths[0] + defaultWidths[1]);
155
157}
static const D3D_BLOB_PART parts[]
Definition: blob.c:76
#define SB_SETPARTS
Definition: commctrl.h:1954
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_StatusBarUpdateAll()

static VOID DIALOG_StatusBarUpdateAll ( VOID  )
static

Definition at line 180 of file dialog.c.

181{
185}
VOID DIALOG_StatusBarUpdateCaretPos(VOID)
Definition: dialog.c:920
static VOID DIALOG_StatusBarUpdateEncoding(VOID)
Definition: dialog.c:168
static VOID DIALOG_StatusBarUpdateLineEndings(VOID)
Definition: dialog.c:159

Referenced by DIALOG_FileNew(), DIALOG_FileSaveAs(), DoOpenFile(), and DoShowHideStatusBar().

◆ DIALOG_StatusBarUpdateCaretPos()

VOID DIALOG_StatusBarUpdateCaretPos ( VOID  )

Definition at line 920 of file dialog.c.

921{
922 int line, ich, col;
924 DWORD dwStart, dwSize;
925
926 SendMessage(Globals.hEdit, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwSize);
927 line = SendMessage(Globals.hEdit, EM_LINEFROMCHAR, (WPARAM)dwStart, 0);
928 ich = (int)SendMessage(Globals.hEdit, EM_LINEINDEX, (WPARAM)line, 0);
929
930 /* EM_LINEINDEX can return -1 on failure */
931 col = ((ich < 0) ? 0 : (dwStart - ich));
932
933 StringCchPrintf(buff, _countof(buff), Globals.szStatusBarLineCol, line + 1, col + 1);
935}
#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:1949
#define StringCchPrintf
Definition: strsafe.h:517
Definition: parser.c:49

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

◆ DIALOG_StatusBarUpdateEncoding()

static VOID DIALOG_StatusBarUpdateEncoding ( VOID  )
static

Definition at line 168 of file dialog.c.

169{
170 WCHAR szText[128] = L"";
171
172 if (Globals.encFile != ENCODING_AUTO)
173 {
174 LoadStringW(Globals.hInstance, EncToStrId[Globals.encFile], szText, _countof(szText));
175 }
176
178}
static UINT EncToStrId[]
Definition: dialog.c:37
#define SBPART_ENCODING
Definition: dialog.c:27
@ ENCODING_AUTO
Definition: notepad.h:41
#define L(x)
Definition: ntvdm.h:50
#define SB_SETTEXTW
Definition: commctrl.h:1942

Referenced by DIALOG_StatusBarUpdateAll().

◆ DIALOG_StatusBarUpdateLineEndings()

static VOID DIALOG_StatusBarUpdateLineEndings ( VOID  )
static

Definition at line 159 of file dialog.c.

160{
161 WCHAR szText[128];
162
163 LoadStringW(Globals.hInstance, EolnToStrId[Globals.iEoln], szText, _countof(szText));
164
165 SendMessageW(Globals.hStatusBar, SB_SETTEXTW, SBPART_EOLN, (LPARAM)szText);
166}
#define SBPART_EOLN
Definition: dialog.c:26
static UINT EolnToStrId[]
Definition: dialog.c:30

Referenced by DIALOG_StatusBarUpdateAll().

◆ DIALOG_StringMsgBox()

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

Definition at line 187 of file dialog.c.

188{
189 TCHAR szMessage[MAX_STRING_LEN];
190 TCHAR szResource[MAX_STRING_LEN];
191
192 /* Load and format szMessage */
193 LoadString(Globals.hInstance, formatId, szResource, _countof(szResource));
194 StringCchPrintf(szMessage, _countof(szMessage), szResource, szString);
195
196 /* Load szCaption */
198 LoadString(Globals.hInstance, STRING_ERROR, szResource, _countof(szResource));
199 else
200 LoadString(Globals.hInstance, STRING_NOTEPAD, szResource, _countof(szResource));
201
202 /* Display Modal Dialog */
203 // if (hParent == NULL)
204 // hParent = Globals.hMainWnd;
205 return MessageBox(hParent, szMessage, szResource, dwFlags);
206}
#define STRING_ERROR
Definition: notepad_res.h:64
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define MB_ICONMASK
Definition: winuser.h:819
#define MessageBox
Definition: winuser.h:5822

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

◆ DIALOG_ViewStatusBar()

VOID DIALOG_ViewStatusBar ( VOID  )

Definition at line 937 of file dialog.c.

938{
939 Globals.bShowStatusBar = !Globals.bShowStatusBar;
941}

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

302{
303 int nResult;
304
305 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
306 {
307 /* prompt user to save changes */
308 nResult = AlertFileNotSaved(Globals.szFileName);
309 switch (nResult)
310 {
311 case IDYES:
312 if(!DIALOG_FileSave())
313 return FALSE;
314 break;
315
316 case IDNO:
317 break;
318
319 case IDCANCEL:
320 default:
321 return FALSE;
322 }
323 }
324
327
328 return TRUE;
329}
static const TCHAR empty_str[]
Definition: dialog.c:20
static int AlertFileNotSaved(LPCTSTR szFileName)
Definition: dialog.c:213
BOOL DIALOG_FileSave(VOID)
Definition: dialog.c:446
#define EM_GETMODIFY
Definition: winuser.h:1994
#define IDNO
Definition: winuser.h:836
#define IDYES
Definition: winuser.h:835

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

◆ DoCreateEditWindow()

VOID DoCreateEditWindow ( VOID  )

Definition at line 654 of file dialog.c.

655{
656 DWORD dwStyle;
657 int iSize;
658 LPTSTR pTemp = NULL;
659 BOOL bModified = FALSE;
660
661 iSize = 0;
662
663 /* If the edit control already exists, try to save its content */
664 if (Globals.hEdit != NULL)
665 {
666 /* number of chars currently written into the editor. */
667 iSize = GetWindowTextLength(Globals.hEdit);
668 if (iSize)
669 {
670 /* Allocates temporary buffer. */
671 pTemp = HeapAlloc(GetProcessHeap(), 0, (iSize + 1) * sizeof(TCHAR));
672 if (!pTemp)
673 {
675 return;
676 }
677
678 /* Recover the text into the control. */
679 GetWindowText(Globals.hEdit, pTemp, iSize + 1);
680
681 if (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0))
682 bModified = TRUE;
683 }
684
685 /* Restore original window procedure */
687
688 /* Destroy the edit control */
689 DestroyWindow(Globals.hEdit);
690 }
691
692 /* Update wrap status into the main menu and recover style flags */
693 dwStyle = (Globals.bWrapLongLines ? EDIT_STYLE_WRAP : EDIT_STYLE);
694
695 /* Create the new edit control */
698 NULL,
699 dwStyle,
705 NULL,
707 NULL);
708 if (Globals.hEdit == NULL)
709 {
710 if (pTemp)
711 {
712 HeapFree(GetProcessHeap(), 0, pTemp);
713 }
714
716 return;
717 }
718
720 SendMessage(Globals.hEdit, EM_LIMITTEXT, 0, 0);
721
722 /* If some text was previously saved, restore it. */
723 if (iSize != 0)
724 {
725 SetWindowText(Globals.hEdit, pTemp);
726 HeapFree(GetProcessHeap(), 0, pTemp);
727
728 if (bModified)
730 }
731
732 /* Sub-class a new window callback for row/column detection. */
733 Globals.EditProc = (WNDPROC)SetWindowLongPtr(Globals.hEdit,
736
737 /* Finally shows new edit control and set focus into it. */
738 ShowWindow(Globals.hEdit, SW_SHOW);
739 SetFocus(Globals.hEdit);
740
741 /* Re-arrange controls */
743}
LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: main.c:294
VOID ShowLastError(VOID)
Definition: dialog.c:45
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned int BOOL
Definition: ntddk_ex.h:94
__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:5755
#define EM_LIMITTEXT
Definition: winuser.h:2000
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:1611
#define GetWindowText
Definition: winuser.h:5798
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SW_SHOW
Definition: winuser.h:775
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2906
BOOL WINAPI DestroyWindow(_In_ HWND)
#define EM_SETMODIFY
Definition: winuser.h:2013
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by DIALOG_EditWrap(), and NOTEPAD_WndProc().

◆ DoOpenFile()

VOID DoOpenFile ( LPCTSTR  szFileName)

Definition at line 331 of file dialog.c.

332{
334 TCHAR log[5];
335 HLOCAL hLocal;
336
337 /* Close any files and prompt to save changes */
338 if (!DoCloseFile())
339 return;
340
342
346 {
348 goto done;
349 }
350
351 /* To make loading file quicker, we use the internal handle of EDIT control */
352 hLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0);
353 if (!ReadText(hFile, &hLocal, &Globals.encFile, &Globals.iEoln))
354 {
356 goto done;
357 }
358 SendMessageW(Globals.hEdit, EM_SETHANDLE, (WPARAM)hLocal, 0);
359 /* No need of EM_SETMODIFY and EM_EMPTYUNDOBUFFER here. EM_SETHANDLE does instead. */
360
361 SetFocus(Globals.hEdit);
362
363 /* If the file starts with .LOG, add a time/date at the end and set cursor after
364 * See http://web.archive.org/web/20090627165105/http://support.microsoft.com/kb/260563
365 */
366 if (GetWindowText(Globals.hEdit, log, _countof(log)) && !_tcscmp(log, _T(".LOG")))
367 {
368 static const TCHAR lf[] = _T("\r\n");
373 }
374
375 SetFileName(szFileName);
379
380done:
384}
VOID DIALOG_EditTimeDate(VOID)
Definition: dialog.c:604
#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:3684
HANDLE HLOCAL
Definition: windef.h:244
#define EM_GETHANDLE
Definition: winuser.h:1989
#define EM_SETHANDLE
Definition: winuser.h:2009

Referenced by DIALOG_FileOpen().

◆ DoSaveFile()

static BOOL DoSaveFile ( VOID  )
static

Definition at line 244 of file dialog.c.

245{
246 BOOL bRet = FALSE;
249
251
255 {
258 return FALSE;
259 }
260
262 if (cchText <= 0)
263 {
264 bRet = TRUE;
265 }
266 else
267 {
268 HLOCAL hLocal = (HLOCAL)SendMessageW(Globals.hEdit, EM_GETHANDLE, 0, 0);
269 LPWSTR pszText = LocalLock(hLocal);
270 if (pszText)
271 {
272 bRet = WriteText(hFile, pszText, cchText, Globals.encFile, Globals.iEoln);
273 if (!bRet)
275
276 LocalUnlock(hLocal);
277 }
278 else
279 {
281 }
282 }
283
285
286 if (bRet)
287 {
289 SetFileName(Globals.szFileName);
290 }
291
293 return bRet;
294}
#define CreateFileW
Definition: compat.h:741
LPVOID NTAPI LocalLock(HLOCAL hMem)
Definition: heapmem.c:1616
BOOL NTAPI LocalUnlock(HLOCAL hMem)
Definition: heapmem.c:1805
#define CREATE_ALWAYS
Definition: disk.h:72
BOOL WriteText(HANDLE hFile, LPCWSTR pszText, DWORD dwTextLen, ENCODING encFile, EOLN iEoln)
Definition: text.c:395
#define GENERIC_WRITE
Definition: nt_native.h:90
_In_ int cchText
Definition: winuser.h:4465
int WINAPI GetWindowTextLengthW(_In_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DIALOG_FileSave(), and DIALOG_FileSaveAs().

◆ DoShowHideStatusBar()

VOID DoShowHideStatusBar ( VOID  )

Definition at line 620 of file dialog.c.

621{
622 /* Check if status bar object already exists. */
623 if (Globals.bShowStatusBar && Globals.hStatusBar == NULL)
624 {
625 /* Try to create the status bar */
627 NULL,
630
631 if (Globals.hStatusBar == NULL)
632 {
634 return;
635 }
636
637 /* Load the string for formatting column/row text output */
639 }
640
641 /* Update layout of controls */
643
644 if (Globals.hStatusBar == NULL)
645 return;
646
647 /* Update visibility of status bar */
648 ShowWindow(Globals.hStatusBar, (Globals.bShowStatusBar ? SW_SHOWNOACTIVATE : SW_HIDE));
649
650 /* Update status bar contents */
652}
#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:1933
#define CCS_BOTTOM
Definition: commctrl.h:2244
#define SBARS_SIZEGRIP
Definition: commctrl.h:1923
#define SW_HIDE
Definition: winuser.h:768
#define SW_SHOWNOACTIVATE
Definition: winuser.h:774

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

◆ EDIT_WndProc()

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

Definition at line 294 of file main.c.

295{
296 switch (msg)
297 {
298 case WM_KEYDOWN:
299 case WM_KEYUP:
300 {
301 switch (wParam)
302 {
303 case VK_UP:
304 case VK_DOWN:
305 case VK_LEFT:
306 case VK_RIGHT:
308 break;
309 default:
310 {
312 break;
313 }
314 }
315 }
316 case WM_LBUTTONUP:
317 {
319 break;
320 }
321 }
322 return CallWindowProc( Globals.EditProc, hWnd, msg, wParam, lParam);
323}
HWND hWnd
Definition: settings.c:17
OSK_GLOBALS Globals
Definition: main.c:16
void UpdateWindowCaption(HWND hwnd)
Definition: mplay32.c:102
#define WM_KEYUP
Definition: winuser.h:1716
#define CallWindowProc
Definition: winuser.h:5735
#define VK_UP
Definition: winuser.h:2225
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define VK_LEFT
Definition: winuser.h:2224
#define VK_RIGHT
Definition: winuser.h:2226
#define VK_DOWN
Definition: winuser.h:2227
#define WM_KEYDOWN
Definition: winuser.h:1715

Referenced by DoCreateEditWindow().

◆ FileExists()

BOOL FileExists ( LPCTSTR  szFilename)

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

Definition at line 229 of file dialog.c.

230{
231 return GetFileAttributes(szFilename) != INVALID_FILE_ATTRIBUTES;
232}
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GetFileAttributes
Definition: winbase.h:3750

Referenced by DIALOG_FileOpen(), and HandleCommandLine().

◆ HasFileExtension()

BOOL HasFileExtension ( LPCTSTR  szFilename)

Definition at line 234 of file dialog.c.

235{
236 LPCTSTR s;
237
238 s = _tcsrchr(szFilename, _T('\\'));
239 if (s)
240 szFilename = s;
241 return _tcsrchr(szFilename, _T('.')) != NULL;
242}
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
54
56 NULL,
57 error,
58 0,
59 (LPTSTR) &lpMsgBuf,
60 0,
61 NULL);
62
64 LocalFree(lpMsgBuf);
65 }
66}
#define NO_ERROR
Definition: dderror.h:5
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
#define error(str)
Definition: mkdosfs.c:1605
#define FormatMessage
Definition: winbase.h:3730
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
#define MB_ICONERROR
Definition: winuser.h:787

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

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

115{
116 static HCURSOR s_hWaitCursor = NULL;
117 static HCURSOR s_hOldCursor = NULL;
118 static INT s_nLock = 0;
119
120 if (bBegin)
121 {
122 if (s_nLock++ == 0)
123 {
124 if (s_hWaitCursor == NULL)
125 s_hWaitCursor = LoadCursor(NULL, IDC_WAIT);
126 s_hOldCursor = SetCursor(s_hWaitCursor);
127 }
128 else
129 {
130 SetCursor(s_hWaitCursor);
131 }
132 }
133 else
134 {
135 if (--s_nLock == 0)
136 SetCursor(s_hOldCursor);
137 }
138}
HICON HCURSOR
Definition: windef.h:299
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define LoadCursor
Definition: winuser.h:5812
#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().

Variable Documentation

◆ empty_str

◆ EncToStrId

UINT EncToStrId[]
static
Initial value:

Definition at line 37 of file dialog.c.

Referenced by DIALOG_StatusBarUpdateEncoding().

◆ EolnToStrId

UINT EolnToStrId[]
static
Initial value:

Definition at line 30 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 21 of file dialog.c.

Referenced by DIALOG_FileOpen(), and DIALOG_FileSaveAs().

◆ txt_files

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

Definition at line 22 of file dialog.c.

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