[NOTEPAD] Less flickering title bar (#4516)

When typing text on NotePad, then NotePad title bar flickers.
- Save previous modification flag.
- If no change in modification flag, do not set the title bar text.
This commit is contained in:
Katayama Hirofumi MZ 2022-05-15 14:38:43 +09:00 committed by GitHub
parent 99d9fc698f
commit 1d690f0411
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -68,6 +68,13 @@ void UpdateWindowCaption(BOOL clearModifyAlert)
TCHAR szCaption[MAX_STRING_LEN];
TCHAR szNotepad[MAX_STRING_LEN];
TCHAR szFilename[MAX_STRING_LEN];
BOOL isModified = !!SendMessage(Globals.hEdit, EM_GETMODIFY, 0, 0);
if (!clearModifyAlert && isModified == Globals.bWasModified)
{
/* We are in the same state as before, don't change the caption */
return;
}
/* Load the name of the application */
LoadString(Globals.hInstance, STRING_NOTEPAD, szNotepad, ARRAY_SIZE(szNotepad));
@ -84,14 +91,17 @@ void UpdateWindowCaption(BOOL clearModifyAlert)
{
StringCbPrintf(szCaption, sizeof(szCaption), _T("%s - %s"),
szFilename, szNotepad);
Globals.bWasModified = FALSE;
}
else
{
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, sizeof(szCaption), _T("%s%s - %s"),
(isModified ? _T("*") : _T("")), szFilename, szNotepad);
/* We will modify the caption below */
Globals.bWasModified = isModified;
}
/* Update the window caption */

View file

@ -80,6 +80,7 @@ typedef struct
FINDREPLACE find;
WNDPROC EditProc;
RECT main_rect;
BOOL bWasModified;
} NOTEPAD_GLOBALS;
extern NOTEPAD_GLOBALS Globals;