TTreeView-折叠和展开未指定的图像 [英] TTreeView - Collapse and Expand Images not Alligned

查看:112
本文介绍了TTreeView-折叠和展开未指定的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道我如何将折叠/展开图像与图标中心对齐吗?
使用白色主题是正确的,但在黑暗主题中,箭头似乎是底部对齐:

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:

推荐答案

如果您使用的是VCL样式Utils组件,请在Vcl.Styles.UxTheme中修改UxTheme_TreeView。 pas

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;

还设置树视图属性 ShowLines:= false;

这篇关于TTreeView-折叠和展开未指定的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆