Skip to content

Commit

Permalink
Save System Information window state
Browse files Browse the repository at this point in the history
  • Loading branch information
wj32 committed Feb 15, 2016
1 parent 43b6ead commit 99ce8d4
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ProcessHacker/include/mainwndp.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ VOID PhMwpSaveSettings(
VOID
);

VOID PhMwpSaveWindowSettings(
VOID PhMwpSaveWindowState(
VOID
);

Expand Down
10 changes: 10 additions & 0 deletions ProcessHacker/include/sysinfop.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ VOID PhSipOnShowWindow(
_In_ ULONG State
);

BOOLEAN PhSipOnSysCommand(
_In_ ULONG Type,
_In_ LONG CursorScreenX,
_In_ LONG CursorScreenY
);

VOID PhSipOnSize(
VOID
);
Expand Down Expand Up @@ -198,6 +204,10 @@ VOID PhSipSetAlwaysOnTop(
VOID
);

VOID PhSipSaveWindowState(
VOID
);

VOID NTAPI PhSipSysInfoUpdateHandler(
_In_opt_ PVOID Parameter,
_In_opt_ PVOID Context
Expand Down
9 changes: 4 additions & 5 deletions ProcessHacker/mainwnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1818,9 +1818,8 @@ BOOLEAN PhMwpOnSysCommand(
break;
case SC_MINIMIZE:
{
// Save the current window state because we
// may not have a chance to later.
PhMwpSaveWindowSettings();
// Save the current window state because we may not have a chance to later.
PhMwpSaveWindowState();

if (PhGetIntegerSetting(L"HideOnMinimize") && PhNfTestIconMask(PH_ICON_ALL))
{
Expand Down Expand Up @@ -2645,13 +2644,13 @@ VOID PhMwpSaveSettings(

PhSaveWindowPlacementToSetting(L"MainWindowPosition", L"MainWindowSize", PhMainWndHandle);

PhMwpSaveWindowSettings();
PhMwpSaveWindowState();

if (PhSettingsFileName)
PhSaveSettings(PhSettingsFileName->Buffer);
}

VOID PhMwpSaveWindowSettings(
VOID PhMwpSaveWindowState(
VOID
)
{
Expand Down
1 change: 1 addition & 0 deletions ProcessHacker/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ VOID PhSettingsInitialization(
PhpAddIntegerPairSetting(L"SysInfoWindowPosition", L"200,200");
PhpAddStringSetting(L"SysInfoWindowSection", L"");
PhpAddIntegerPairSetting(L"SysInfoWindowSize", L"620,590");
PhpAddIntegerSetting(L"SysInfoWindowState", L"1");
PhpAddIntegerSetting(L"ThinRows", L"0");
PhpAddStringSetting(L"ThreadTreeListColumns", L"");
PhpAddStringSetting(L"ThreadTreeListSort", L"1,2"); // 1, DescendingSortOrder
Expand Down
43 changes: 43 additions & 0 deletions ProcessHacker/sysinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ INT_PTR CALLBACK PhSipSysInfoDialogProc(
PhSipOnShowWindow(!!wParam, (ULONG)lParam);
}
break;
case WM_SYSCOMMAND:
{
if (PhSipOnSysCommand((ULONG)wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)))
return 0;
}
break;
case WM_SIZE:
{
PhSipOnSize();
Expand Down Expand Up @@ -380,6 +386,7 @@ VOID PhSipOnDestroy(
PhSetIntegerSetting(L"SysInfoWindowAlwaysOnTop", AlwaysOnTop);

PhSaveWindowPlacementToSetting(L"SysInfoWindowPosition", L"SysInfoWindowSize", PhSipWindow);
PhSipSaveWindowState();
}

VOID PhSipOnNcDestroy(
Expand Down Expand Up @@ -511,6 +518,9 @@ VOID PhSipOnShowWindow(

PhLoadWindowPlacementFromSetting(L"SysInfoWindowPosition", L"SysInfoWindowSize", PhSipWindow);

if (PhGetIntegerSetting(L"SysInfoWindowState") == SW_MAXIMIZE)
ShowWindow(PhSipWindow, SW_MAXIMIZE);

if (InitialSectionName)
PhInitializeStringRefLongHint(&sectionName, InitialSectionName);
else
Expand All @@ -529,6 +539,25 @@ VOID PhSipOnShowWindow(
PhSipOnUserMessage(SI_MSG_SYSINFO_UPDATE, 0, 0);
}

BOOLEAN PhSipOnSysCommand(
_In_ ULONG Type,
_In_ LONG CursorScreenX,
_In_ LONG CursorScreenY
)
{
switch (Type)
{
case SC_MINIMIZE:
{
// Save the current window state because we may not have a chance to later.
PhSipSaveWindowState();
}
break;
}

return FALSE;
}

VOID PhSipOnSize(
VOID
)
Expand Down Expand Up @@ -2020,6 +2049,20 @@ VOID PhSipSetAlwaysOnTop(
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
}

VOID PhSipSaveWindowState(
VOID
)
{
WINDOWPLACEMENT placement = { sizeof(placement) };

GetWindowPlacement(PhSipWindow, &placement);

if (placement.showCmd == SW_NORMAL)
PhSetIntegerSetting(L"SysInfoWindowState", SW_NORMAL);
else if (placement.showCmd == SW_MAXIMIZE)
PhSetIntegerSetting(L"SysInfoWindowState", SW_MAXIMIZE);
}

VOID NTAPI PhSipSysInfoUpdateHandler(
_In_opt_ PVOID Parameter,
_In_opt_ PVOID Context
Expand Down

0 comments on commit 99ce8d4

Please sign in to comment.