X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=reactos%2Fbase%2Fapplications%2Fnotepad%2Fdialog.c;h=afc96abb2ef1cf672ad8ad46c97352a174aea7ee;hp=827e58d40e01ee7343532166ff761db84e48789a;hb=8e9e71dcfbd344f9d0f6bb8c1326913e8b6269db;hpb=93fe673fa4764c211da371ca886b7c45ba07149a diff --git a/reactos/base/applications/notepad/dialog.c b/reactos/base/applications/notepad/dialog.c index 827e58d40e0..afc96abb2ef 100644 --- a/reactos/base/applications/notepad/dialog.c +++ b/reactos/base/applications/notepad/dialog.c @@ -63,24 +63,35 @@ VOID ShowLastError(VOID) * (untitled) - Notepad if no file is open * [filename] - Notepad if a file is given */ -static void UpdateWindowCaption(void) +void UpdateWindowCaption(BOOL clearModifyAlert) { TCHAR szCaption[MAX_STRING_LEN]; TCHAR szNotepad[MAX_STRING_LEN]; + TCHAR szFilename[MAX_STRING_LEN]; + /* Load the name of the application */ LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad)); + /* Determine if the file has been saved or if this is a new file */ if (Globals.szFileTitle[0] != 0) - { - StringCchCopy(szCaption, ARRAY_SIZE(szCaption), Globals.szFileTitle); - } + StringCchCopy(szFilename, ARRAY_SIZE(szFilename), Globals.szFileTitle); + else + LoadString(Globals.hInstance, STRING_UNTITLED, szFilename, ARRAY_SIZE(szFilename)); + + /* When a file is being opened or created, there is no need to have the edited flag shown + when the new or opened file has not been edited yet */ + if (clearModifyAlert) + StringCbPrintf(szCaption, ARRAY_SIZE(szCaption), _T("%s - %s"), szFilename, szNotepad); else { - LoadString(Globals.hInstance, STRING_UNTITLED, szCaption, ARRAY_SIZE(szCaption)); + BOOL isModified = (SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0) ? TRUE : FALSE); + + /* Update the caption based upon if the user has modified the contents of the file or not */ + StringCbPrintf(szCaption, ARRAY_SIZE(szCaption), _T("%s%s - %s"), + (isModified ? _T("*") : _T("")), szFilename, szNotepad); } - StringCchCat(szCaption, ARRAY_SIZE(szCaption), _T(" - ")); - StringCchCat(szCaption, ARRAY_SIZE(szCaption), szNotepad); + /* Update the window caption */ SetWindowText(Globals.hMainWnd, szCaption); } @@ -326,7 +337,7 @@ BOOL DoCloseFile(VOID) } SetFileName(empty_str); - UpdateWindowCaption(); + UpdateWindowCaption(TRUE); return TRUE; } @@ -375,7 +386,7 @@ VOID DoOpenFile(LPCTSTR szFileName) } SetFileName(szFileName); - UpdateWindowCaption(); + UpdateWindowCaption(TRUE); NOTEPAD_EnableSearchMenu(); done: if (hFile != INVALID_HANDLE_VALUE) @@ -522,7 +533,7 @@ BOOL DIALOG_FileSaveAs(VOID) SetFileName(szPath); if (DoSaveFile()) { - UpdateWindowCaption(); + UpdateWindowCaption(TRUE); return TRUE; } else