update main window title on set focus
@@ -67,42 +67,18 @@ static HMENU SubMenuHandles[5];
static PPH_EMENU SubMenuObjects[5];
static ULONG SelectedUserSessionId = ULONG_MAX;
-BOOLEAN PhMainWndInitialization(
- _In_ INT ShowCommand
+PPH_STRING PhGetMainWindowTitle(
+ VOID
)
-{
- RTL_ATOM windowAtom;
- PPH_STRING windowName;
- PH_RECTANGLE windowRectangle = {0};
- RECT rect;
- HMENU windowMenuHandle = NULL;
- LONG dpiValue;
-
- // Set FirstRun default settings.
-
- if (PhGetIntegerSetting(L"FirstRun"))
- PhSetIntegerSetting(L"FirstRun", FALSE);
-
- // Initialize the window.
-
- if ((windowAtom = PhMwpInitializeWindowClass()) == INVALID_ATOM)
- return FALSE;
-
- windowRectangle.Position = PhGetIntegerPairSetting(L"MainWindowPosition");
-
- rect = PhRectangleToRect(windowRectangle);
- dpiValue = PhGetMonitorDpi(&rect);
-
- windowRectangle.Size = PhGetScalableIntegerPairSetting(L"MainWindowSize", TRUE, dpiValue).Pair;
-
- // Create the window title.
- windowName = NULL;
-
- if (PhGetIntegerSetting(L"EnableWindowText"))
{
PH_STRING_BUILDER stringBuilder;
PPH_STRING currentUserName;
+ if (!PhGetIntegerSetting(L"EnableWindowText"))
+ {
+ return NULL;
+ }
+
PhInitializeStringBuilder(&stringBuilder, 100);
PhAppendStringBuilder2(&stringBuilder, PhApplicationName);
@@ -136,9 +112,40 @@ BOOLEAN PhMainWndInitialization(
if (PhGetOwnTokenAttributes().ElevationType == TokenElevationTypeFull)
PhAppendStringBuilder2(&stringBuilder, L" (Administrator)");
- windowName = PhFinalStringBuilderString(&stringBuilder);
+ return PhFinalStringBuilderString(&stringBuilder);
}
- else
+
+BOOLEAN PhMainWndInitialization(
+ _In_ INT ShowCommand
+ )
+{
+ RTL_ATOM windowAtom;
+ PPH_STRING windowName;
+ PH_RECTANGLE windowRectangle = {0};
+ RECT rect;
+ HMENU windowMenuHandle = NULL;
+ LONG dpiValue;
+
+ // Set FirstRun default settings.
+
+ if (PhGetIntegerSetting(L"FirstRun"))
+ PhSetIntegerSetting(L"FirstRun", FALSE);
+
+ // Initialize the window.
+
+ if ((windowAtom = PhMwpInitializeWindowClass()) == INVALID_ATOM)
+ return FALSE;
+
+ windowRectangle.Position = PhGetIntegerPairSetting(L"MainWindowPosition");
+
+ rect = PhRectangleToRect(windowRectangle);
+ dpiValue = PhGetMonitorDpi(&rect);
+
+ windowRectangle.Size = PhGetScalableIntegerPairSetting(L"MainWindowSize", TRUE, dpiValue).Pair;
+
+ // Create the window title.
+ windowName = PhGetMainWindowTitle();
+ if (!windowName)
{
PhApplicationName = L" "; // Remove dialog window title when disabled (dmex)
}
@@ -2031,6 +2038,13 @@ VOID PhMwpOnSetFocus(
VOID
)
{
+ PPH_STRING windowTitle = PhGetMainWindowTitle();
+
+ SetWindowText(PhMainWndHandle, PhGetString(windowTitle));
+
+ if (windowTitle)
+ PhDereferenceObject(windowTitle);
+
if (CurrentPage->WindowHandle)
SetFocus(CurrentPage->WindowHandle);
}
