Skip to content

Commit 351c5fb

Browse files
committed
Update legacy custom color dialog preferences
1 parent 44ba8c6 commit 351c5fb

File tree

3 files changed

+17
-58
lines changed

3 files changed

+17
-58
lines changed

ProcessHacker/options.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,9 +3400,13 @@ INT_PTR CALLBACK PhpOptionsHighlightingDlgProc(
34003400

34013401
if (item = PhGetSelectedListViewItemParam(HighlightingListViewHandle))
34023402
{
3403-
CHOOSECOLOR chooseColor = { sizeof(CHOOSECOLOR) };
3403+
CHOOSECOLOR chooseColor;
34043404
COLORREF customColors[16] = { 0 };
34053405

3406+
PhLoadCustomColorList(L"OptionsCustomColorList", customColors, RTL_NUMBER_OF(customColors));
3407+
3408+
memset(&chooseColor, 0, sizeof(CHOOSECOLOR));
3409+
chooseColor.lStructSize = sizeof(CHOOSECOLOR);
34063410
chooseColor.hwndOwner = hwndDlg;
34073411
chooseColor.rgbResult = item->CurrentColor;
34083412
chooseColor.lpCustColors = customColors;
@@ -3414,6 +3418,8 @@ INT_PTR CALLBACK PhpOptionsHighlightingDlgProc(
34143418
item->CurrentColor = chooseColor.rgbResult;
34153419
InvalidateRect(HighlightingListViewHandle, NULL, TRUE);
34163420
}
3421+
3422+
PhSaveCustomColorList(L"OptionsCustomColorList", customColors, RTL_NUMBER_OF(customColors));
34173423
}
34183424
}
34193425
}
@@ -3547,9 +3553,13 @@ INT_PTR CALLBACK PhpOptionsGraphsDlgProc(
35473553

35483554
if (item = PhGetSelectedListViewItemParam(PhpGraphListViewHandle))
35493555
{
3550-
CHOOSECOLOR chooseColor = { sizeof(CHOOSECOLOR) };
3556+
CHOOSECOLOR chooseColor;
35513557
COLORREF customColors[16] = { 0 };
35523558

3559+
PhLoadCustomColorList(L"OptionsCustomColorList", customColors, RTL_NUMBER_OF(customColors));
3560+
3561+
memset(&chooseColor, 0, sizeof(CHOOSECOLOR));
3562+
chooseColor.lStructSize = sizeof(CHOOSECOLOR);
35533563
chooseColor.hwndOwner = hwndDlg;
35543564
chooseColor.rgbResult = item->CurrentColor;
35553565
chooseColor.lpCustColors = customColors;
@@ -3561,6 +3571,8 @@ INT_PTR CALLBACK PhpOptionsGraphsDlgProc(
35613571
item->CurrentColor = chooseColor.rgbResult;
35623572
InvalidateRect(PhpGraphListViewHandle, NULL, TRUE);
35633573
}
3574+
3575+
PhSaveCustomColorList(L"OptionsCustomColorList", customColors, RTL_NUMBER_OF(customColors));
35643576
}
35653577
}
35663578
}

ProcessHacker/settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ VOID PhAddDefaultSettings(
159159
PhpAddStringSetting(L"NetworkTreeListColumns", L"");
160160
PhpAddStringSetting(L"NetworkTreeListSort", L"0,1"); // 0, AscendingSortOrder
161161
PhpAddIntegerSetting(L"NoPurgeProcessRecords", L"0");
162+
PhpAddStringSetting(L"OptionsCustomColorList", L"");
162163
PhpAddStringSetting(L"OptionsWindowAdvancedColumns", L"");
163164
PhpAddIntegerSetting(L"OptionsWindowAdvancedFlags", L"0");
164165
PhpAddIntegerPairSetting(L"OptionsWindowPosition", L"0,0");

plugins/UserNotes/main.c

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -122,60 +122,6 @@ VOID DeleteDbObjectForProcessIfUnused(
122122
}
123123
}
124124

125-
VOID LoadCustomColors(
126-
VOID
127-
)
128-
{
129-
PPH_STRING settingsString;
130-
PH_STRINGREF remaining;
131-
PH_STRINGREF part;
132-
133-
settingsString = PhaGetStringSetting(SETTING_NAME_CUSTOM_COLOR_LIST);
134-
135-
if (PhIsNullOrEmptyString(settingsString))
136-
return;
137-
138-
remaining = PhGetStringRef(settingsString);
139-
140-
for (ULONG i = 0; i < RTL_NUMBER_OF(ProcessCustomColors); i++)
141-
{
142-
ULONG64 integer = 0;
143-
144-
if (remaining.Length == 0)
145-
break;
146-
147-
PhSplitStringRefAtChar(&remaining, L',', &part, &remaining);
148-
149-
if (PhStringToInteger64(&part, 10, &integer))
150-
{
151-
ProcessCustomColors[i] = (COLORREF)integer;
152-
}
153-
}
154-
}
155-
156-
PPH_STRING SaveCustomColors(
157-
VOID
158-
)
159-
{
160-
PH_STRING_BUILDER stringBuilder;
161-
162-
PhInitializeStringBuilder(&stringBuilder, 100);
163-
164-
for (ULONG i = 0; i < RTL_NUMBER_OF(ProcessCustomColors); i++)
165-
{
166-
PhAppendFormatStringBuilder(
167-
&stringBuilder,
168-
L"%lu,",
169-
ProcessCustomColors[i]
170-
);
171-
}
172-
173-
if (stringBuilder.String->Length != 0)
174-
PhRemoveEndStringBuilder(&stringBuilder, 1);
175-
176-
return PhFinalStringBuilderString(&stringBuilder);
177-
}
178-
179125
NTSTATUS GetProcessAffinity(
180126
_In_ HANDLE ProcessHandle,
181127
_Out_ PKAFFINITY Affinity
@@ -1184,7 +1130,7 @@ VOID NTAPI MenuItemCallback(
11841130
{
11851131
CHOOSECOLOR chooseColor;
11861132

1187-
LoadCustomColors();
1133+
PhLoadCustomColorList(SETTING_NAME_CUSTOM_COLOR_LIST, ProcessCustomColors, RTL_NUMBER_OF(ProcessCustomColors));
11881134

11891135
memset(&chooseColor, 0, sizeof(CHOOSECOLOR));
11901136
chooseColor.lStructSize = sizeof(CHOOSECOLOR);
@@ -1195,7 +1141,7 @@ VOID NTAPI MenuItemCallback(
11951141

11961142
if (ChooseColor(&chooseColor))
11971143
{
1198-
PhSetStringSetting2(SETTING_NAME_CUSTOM_COLOR_LIST, &PH_AUTO_T(PH_STRING, SaveCustomColors())->sr);
1144+
PhSaveCustomColorList(SETTING_NAME_CUSTOM_COLOR_LIST, ProcessCustomColors, RTL_NUMBER_OF(ProcessCustomColors));
11991145

12001146
LockDb();
12011147

0 commit comments

Comments
 (0)