Skip to content

Commit

Permalink
ToolStatus: Fix DPI awareness (#1386), improve startup layout and rem…
Browse files Browse the repository at this point in the history
…ove obsolete functions
  • Loading branch information
dmex committed May 31, 2023
1 parent ed78817 commit 9c1cefd
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 120 deletions.
14 changes: 8 additions & 6 deletions plugins/ToolStatus/customizetb.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ VOID CustomizeInsertToolbarButton(
TBBUTTON button;

memset(&button, 0, sizeof(TBBUTTON));

button.idCommand = ItemContext->IdCommand;
button.iBitmap = I_IMAGECALLBACK;
button.fsState = TBSTATE_ENABLED;
button.iString = (INT_PTR)ToolbarGetText(ItemContext->IdCommand);
button.iString = (INT_PTR)(PVOID)ToolbarGetText(ItemContext->IdCommand);

if (ItemContext->IsSeparator)
{
Expand Down Expand Up @@ -878,7 +877,7 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc(
BOOLEAN isSelected = (drawInfo->itemState & ODS_SELECTED) == ODS_SELECTED;
BOOLEAN isFocused = (drawInfo->itemState & ODS_FOCUS) == ODS_FOCUS;

if (drawInfo->itemID == LB_ERR)
if (drawInfo->itemID == UINT_MAX)
break;

if (!(itemContext = (PBUTTON_CONTEXT)ListBox_GetItemData(drawInfo->hwndItem, drawInfo->itemID)))
Expand Down Expand Up @@ -920,10 +919,13 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc(

if (itemContext->IdCommand != 0)
{
PWSTR stringBuffer = ToolbarGetText(itemContext->IdCommand);
SIZE_T stringLength = PhCountStringZ(stringBuffer);

DrawText(
bufferDc,
ToolbarGetText(itemContext->IdCommand),
-1,
stringBuffer,
(INT)stringLength,
&bufferRect,
DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP
);
Expand All @@ -933,7 +935,7 @@ INT_PTR CALLBACK CustomizeToolbarDialogProc(
DrawText(
bufferDc,
L"Separator",
-1,
sizeof(L"Separator") / sizeof(WCHAR),
&bufferRect,
DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP
);
Expand Down
7 changes: 1 addition & 6 deletions plugins/ToolStatus/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,7 @@ FILTER_RESULT_TYPE ProcessTreeFilterMatchTypeCallback(

if (PH_IS_REAL_PROCESS_ID(processNode->ProcessItem->ProcessId))
{
if (processNode->ProcessItem->AlternateProcessIdString)
{
if (PhWordMatchStringRef(&SearchText->sr, &processNode->ProcessItem->AlternateProcessIdString->sr))
return FILTER_RESULT_FOUND_NAME;
}
else if (processNode->ProcessItem->ProcessIdString[0])
if (processNode->ProcessItem->ProcessIdString[0])
{
if (PhWordMatchStringLongHintZ(SearchText, processNode->ProcessItem->ProcessIdString))
return FILTER_RESULT_FOUND_NAME;
Expand Down
40 changes: 22 additions & 18 deletions plugins/ToolStatus/graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ VOID ToolbarGraphLoadSettings(
PH_STRINGREF idPart;
PH_STRINGREF flagsPart;
PH_STRINGREF pluginNamePart;
ULONG64 idInteger;
ULONG64 flagsInteger;
LONG64 idInteger;
LONG64 flagsInteger;

PhSplitStringRefAtChar(&remaining, L'|', &idPart, &remaining);
PhSplitStringRefAtChar(&remaining, L'|', &flagsPart, &remaining);
Expand All @@ -72,12 +72,16 @@ VOID ToolbarGraphLoadSettings(
if (pluginNamePart.Length)
{
if (graph = ToolbarGraphFindByName(&pluginNamePart, (ULONG)idInteger))
graph->Flags |= TOOLSTATUS_GRAPH_ENABLED;
{
SetFlag(graph->Flags, TOOLSTATUS_GRAPH_ENABLED);
}
}
else
{
if (graph = ToolbarGraphFindById((ULONG)idInteger))
graph->Flags |= TOOLSTATUS_GRAPH_ENABLED;
{
SetFlag(graph->Flags, TOOLSTATUS_GRAPH_ENABLED);
}
}
}
}
Expand All @@ -99,7 +103,7 @@ VOID ToolbarGraphSaveSettings(
PPH_TOOLBAR_GRAPH graph = PhpToolbarGraphList->Items[i];
PPH_STRING pluginName;

if (!(graph->Flags & TOOLSTATUS_GRAPH_ENABLED))
if (!FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED))
continue;

pluginName = graph->Plugin ? PhGetPluginName(graph->Plugin) : NULL;
Expand All @@ -108,7 +112,7 @@ VOID ToolbarGraphSaveSettings(
&graphListBuilder,
L"%lu|%lu|%s|",
graph->GraphId,
graph->Flags & TOOLSTATUS_GRAPH_ENABLED ? 1 : 0,
FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED) ? 1 : 0,
PhGetStringOrEmpty(pluginName)
);

Expand Down Expand Up @@ -276,7 +280,7 @@ VOID ToolbarCreateGraphs(
{
PPH_TOOLBAR_GRAPH graph = PhpToolbarGraphList->Items[i];

if (!(graph->Flags & TOOLSTATUS_GRAPH_ENABLED))
if (!FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED))
continue;

ToolbarAddGraph(graph);
Expand All @@ -291,7 +295,7 @@ VOID ToolbarUpdateGraphs(
{
PPH_TOOLBAR_GRAPH graph = PhpToolbarGraphList->Items[i];

if (!(graph->Flags & TOOLSTATUS_GRAPH_ENABLED))
if (!FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED))
continue;

if (!graph->GraphHandle)
Expand All @@ -317,7 +321,7 @@ VOID ToolbarUpdateGraphVisualStates(
{
PPH_TOOLBAR_GRAPH graph = PhpToolbarGraphList->Items[i];

if (!(graph->Flags & TOOLSTATUS_GRAPH_ENABLED))
if (!FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED))
continue;

if (!graph->GraphHandle)
Expand Down Expand Up @@ -362,12 +366,12 @@ VOID ToolbarSetVisibleGraph(
{
if (Visible)
{
Graph->Flags |= TOOLSTATUS_GRAPH_ENABLED;
SetFlag(Graph->Flags, TOOLSTATUS_GRAPH_ENABLED);
ToolbarAddGraph(Graph);
}
else
{
Graph->Flags &= ~TOOLSTATUS_GRAPH_ENABLED;
ClearFlag(Graph->Flags, TOOLSTATUS_GRAPH_ENABLED);
ToolbarRemoveGraph(Graph);
}
}
Expand All @@ -382,7 +386,7 @@ BOOLEAN ToolbarGraphsEnabled(
{
PPH_TOOLBAR_GRAPH graph = PhpToolbarGraphList->Items[i];

if (graph->Flags & TOOLSTATUS_GRAPH_ENABLED)
if (FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED))
{
enabled = TRUE;
break;
Expand Down Expand Up @@ -449,12 +453,12 @@ VOID ToolbarGraphCreateMenu(
graph = PhpToolbarGraphList->Items[i];
menuItem = PhCreateEMenuItem(0, MenuId, graph->Text, NULL, graph);

if (graph->Flags & TOOLSTATUS_GRAPH_ENABLED)
if (FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED))
{
menuItem->Flags |= PH_EMENU_CHECKED;
SetFlag(menuItem->Flags, PH_EMENU_CHECKED);
}

if (graph->Flags & TOOLSTATUS_GRAPH_UNAVAILABLE)
if (FlagOn(graph->Flags, TOOLSTATUS_GRAPH_UNAVAILABLE))
{
PPH_STRING newText;

Expand All @@ -480,12 +484,12 @@ VOID ToolbarGraphCreatePluginMenu(
graph = PhpToolbarGraphList->Items[i];
menuItem = PhPluginCreateEMenuItem(PluginInstance, 0, MenuId, graph->Text, graph);

if (graph->Flags & TOOLSTATUS_GRAPH_ENABLED)
if (FlagOn(graph->Flags, TOOLSTATUS_GRAPH_ENABLED))
{
menuItem->Flags |= PH_EMENU_CHECKED;
SetFlag(menuItem->Flags, PH_EMENU_CHECKED);
}

if (graph->Flags & TOOLSTATUS_GRAPH_UNAVAILABLE)
if (FlagOn(graph->Flags, TOOLSTATUS_GRAPH_UNAVAILABLE))
{
PPH_STRING newText;

Expand Down
Loading

0 comments on commit 9c1cefd

Please sign in to comment.