问题
Does anyone know how I can align the collapse/expand images with the center of my icon? Using a white theme they are correct, but in the dark theme, the arrows seem to be bottom-aligned:
回答1:
If you're using VCL Style Utils components, then modify UxTheme_TreeView in Vcl.Styles.UxTheme.pas
case iPartId of
TVP_GLYPH:
begin
LColor := StyleServices.GetSystemColor(clWindowText);
LRect := pRect;
LRect.Top := LRect.Top + 1; // <---- here's the change
//LRect.Top := LRect.Top + 5;
LRect.Left := LRect.Left + 5;
if (iStateId = GLPS_OPENED) or (iStateId = HGLPS_OPENED) then
DrawStyleArrow(hdc, TScrollDirection.sdDown, LRect.Location, 3, LColor)
else
DrawStyleArrow(hdc, TScrollDirection.sdRight, LRect.Location, 3, LColor);
exit(S_OK);
end;
Also set the tree view property ShowLines := false;
来源:https://stackoverflow.com/questions/61753622/ttreeview-collapse-and-expand-images-not-alligned