TTreeView - Collapse and Expand Images not Alligned

淺唱寂寞╮ 提交于 2020-05-24 07:04:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!