update username on the fly

This commit is contained in:
freedom
2023-08-01 13:03:22 -06:00
parent 9518a5e30b
commit c62bc10490
3 changed files with 42 additions and 20 deletions

View File

@@ -12,7 +12,11 @@
#include "resource.h"
#include "registry.h"
// #define WIN32_LEAN_AND_MEAN
#define SECURITY_WIN32
#include <Windows.h>
#include <strsafe.h>
#include <Lmcons.h>
#include <security.h>
/* Functions */
@@ -143,6 +147,7 @@ LRESULT CALLBACK CmdProc(HWND hWnd, WPARAM wParam, LPARAM lParam)
case IDM_OPTIONS_SHOWUSERNAME:
bShowUsername = !bShowUsername;
UpdateWindowTitle();
UpdateChecks(bShowUsername, IDM_OPTIONS, IDM_OPTIONS_SHOWUSERNAME);
goto SaveConfig;
@@ -192,6 +197,36 @@ VOID UpdateChecks(BOOL bVarMenu, UINT uSubMenu, UINT uID)
return;
}
/* * * *\
UpdateWindowTitle -
Updates Window title based on settings... and
current foreground group window if applicable?
RETURNS -
Nothing!
\* * * */
VOID UpdateWindowTitle()
{
WCHAR szUsername[UNLEN + 1] = L"";
DWORD dwUsernameLen = UNLEN;
WCHAR szWindowTitle[UNLEN + ARRAYSIZE(szAppTitle) + 4] = L"";
// Get user and domain name
GetUserNameEx(NameSamCompatible, szUsername, &dwUsernameLen);
// Add username to window title if settings permit
StringCchCopy(szWindowTitle, ARRAYSIZE(szAppTitle), szAppTitle);
if (bShowUsername)
{
StringCchCat(szWindowTitle, ARRAYSIZE(szWindowTitle), L" - ");
StringCchCat(szWindowTitle, ARRAYSIZE(szWindowTitle), szUsername);
}
SetWindowText(hWndProgMgr, (LPCWSTR)&szWindowTitle);
return;
}
/* * * *\
ChildWndProc -
Program Manager's window procedure.