MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / SetWindowTitle

Function SetWindowTitle

src/Helpers.c:370–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368BOOL bFreezeAppTitle = FALSE;
369
370BOOL SetWindowTitle ( HWND hwnd, UINT uIDAppName, BOOL bIsElevated, UINT uIDUntitled,
371 LPCWSTR lpszFile, int iFormat, BOOL bModified,
372 UINT uIDReadOnly, BOOL bReadOnly, LPCWSTR lpszExcerpt )
373{
374 WCHAR szUntitled[128];
375 WCHAR szExcrptQuot[256];
376 WCHAR szExcrptFmt[32];
377 WCHAR szAppName[128];
378 WCHAR szElevatedAppName[128];
379 WCHAR szReadOnly[32];
380 WCHAR szTitle[512];
381 static WCHAR szCachedFile[MAX_PATH];
382 static WCHAR szCachedDisplayName[MAX_PATH];
383 static const WCHAR *pszSep = L" - ";
384 static const WCHAR *pszMod = L"* ";
385 if ( bFreezeAppTitle ) {
386 return FALSE;
387 }
388 if ( !GetString ( uIDAppName, szAppName, COUNTOF ( szAppName ) ) ||
389 !GetString ( uIDUntitled, szUntitled, COUNTOF ( szUntitled ) ) ) {
390 return FALSE;
391 }
392 if ( bIsElevated ) {
393 FormatString ( szElevatedAppName, COUNTOF ( szElevatedAppName ), IDS_APPTITLE_ELEVATED, szAppName );
394 StrCpyN ( szAppName, szElevatedAppName, COUNTOF ( szAppName ) );
395 }
396 if ( bModified ) {
397 lstrcpy ( szTitle, pszMod );
398 } else {
399 lstrcpy ( szTitle, L"" );
400 }
401 if ( lstrlen ( lpszExcerpt ) ) {
402 GetString ( IDS_TITLEEXCERPT, szExcrptFmt, COUNTOF ( szExcrptFmt ) );
403 wsprintf ( szExcrptQuot, szExcrptFmt, lpszExcerpt );
404 StrCat ( szTitle, szExcrptQuot );
405 } else if ( lstrlen ( lpszFile ) ) {
406 if ( iFormat < 2 && !PathIsRoot ( lpszFile ) ) {
407 if ( lstrcmp ( szCachedFile, lpszFile ) != 0 ) {
408 SHFILEINFO shfi;
409 lstrcpy ( szCachedFile, lpszFile );
410 if ( SHGetFileInfo2 ( lpszFile, 0, &shfi, sizeof ( SHFILEINFO ), SHGFI_DISPLAYNAME ) ) {
411 lstrcpy ( szCachedDisplayName, shfi.szDisplayName );
412 } else {
413 lstrcpy ( szCachedDisplayName, PathFindFileName ( lpszFile ) );
414 }
415 }
416 lstrcat ( szTitle, szCachedDisplayName );
417 if ( iFormat == 1 ) {
418 WCHAR tchPath[MAX_PATH];
419 StrCpyN ( tchPath, lpszFile, COUNTOF ( tchPath ) );
420 PathRemoveFileSpec ( tchPath );
421 StrCat ( szTitle, L" [" );
422 StrCat ( szTitle, tchPath );
423 StrCat ( szTitle, L"]" );
424 }
425 } else {
426 lstrcat ( szTitle, lpszFile );
427 }

Callers 6

InitInstanceFunction · 0.85
MainWndProcFunction · 0.85
MsgCommandFunction · 0.85
MsgNotifyFunction · 0.85
_FileLoadFunction · 0.85
FileSaveFunction · 0.85

Calls 2

FormatStringFunction · 0.85
SHGetFileInfo2Function · 0.85

Tested by

no test coverage detected