mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
[NOTEPAD] Let the user know when an opened file is modified. By Lee Schroeder. CORE-9721
svn path=/trunk/; revision=70207
This commit is contained in:
parent
93fe673fa4
commit
8e9e71dcfb
3 changed files with 28 additions and 10 deletions
|
@ -63,24 +63,35 @@ VOID ShowLastError(VOID)
|
||||||
* (untitled) - Notepad if no file is open
|
* (untitled) - Notepad if no file is open
|
||||||
* [filename] - Notepad if a file is given
|
* [filename] - Notepad if a file is given
|
||||||
*/
|
*/
|
||||||
static void UpdateWindowCaption(void)
|
void UpdateWindowCaption(BOOL clearModifyAlert)
|
||||||
{
|
{
|
||||||
TCHAR szCaption[MAX_STRING_LEN];
|
TCHAR szCaption[MAX_STRING_LEN];
|
||||||
TCHAR szNotepad[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));
|
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)
|
if (Globals.szFileTitle[0] != 0)
|
||||||
{
|
StringCchCopy(szFilename, ARRAY_SIZE(szFilename), Globals.szFileTitle);
|
||||||
StringCchCopy(szCaption, ARRAY_SIZE(szCaption), 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
|
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(" - "));
|
/* Update the window caption */
|
||||||
StringCchCat(szCaption, ARRAY_SIZE(szCaption), szNotepad);
|
|
||||||
SetWindowText(Globals.hMainWnd, szCaption);
|
SetWindowText(Globals.hMainWnd, szCaption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +337,7 @@ BOOL DoCloseFile(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFileName(empty_str);
|
SetFileName(empty_str);
|
||||||
UpdateWindowCaption();
|
UpdateWindowCaption(TRUE);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +386,7 @@ VOID DoOpenFile(LPCTSTR szFileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFileName(szFileName);
|
SetFileName(szFileName);
|
||||||
UpdateWindowCaption();
|
UpdateWindowCaption(TRUE);
|
||||||
NOTEPAD_EnableSearchMenu();
|
NOTEPAD_EnableSearchMenu();
|
||||||
done:
|
done:
|
||||||
if (hFile != INVALID_HANDLE_VALUE)
|
if (hFile != INVALID_HANDLE_VALUE)
|
||||||
|
@ -522,7 +533,7 @@ BOOL DIALOG_FileSaveAs(VOID)
|
||||||
SetFileName(szPath);
|
SetFileName(szPath);
|
||||||
if (DoSaveFile())
|
if (DoSaveFile())
|
||||||
{
|
{
|
||||||
UpdateWindowCaption();
|
UpdateWindowCaption(TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -324,6 +324,11 @@ LRESULT CALLBACK EDIT_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
case VK_RIGHT:
|
case VK_RIGHT:
|
||||||
DIALOG_StatusBarUpdateCaretPos();
|
DIALOG_StatusBarUpdateCaretPos();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
UpdateWindowCaption(FALSE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
|
|
|
@ -20,4 +20,6 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
|
||||||
|
void UpdateWindowCaption(BOOL clearModifyAlert);
|
||||||
|
|
||||||
#endif /* _NOTEPAD_H */
|
#endif /* _NOTEPAD_H */
|
||||||
|
|
Loading…
Reference in a new issue