找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 26|回复: 0

STreeCtrl设置节点文字颜色、选中节点文字颜色,选中节点所有父节点文字颜色

[复制链接]
  • TA的每日心情
    开心
    5 天前
  • 签到天数: 78 天

    [LV.6]常住居民II

    118

    主题

    17

    回帖

    2434

    积分

    管理员

    积分
    2434
    发表于 2026-3-6 23:18:26 | 显示全部楼层 |阅读模式
    2026-03-06_230635.png

    如上图,可设置节点默认的文字颜色(黑),节点选中时文字颜色(绿),节点的所有父节点的文字颜色(红)

    此效果为扩展后的效果,

        /**
         * @brief Text color of selected items's parent.
         */
        COLORREF m_crItemSelParentText;
        /**
         * @brief Flag indicating if lines are drawn between items.
         */

    @@ -811,6 +816,7 @@ class SOUI_EXP STreeCtrl
            ATTR_COLOR(L"colorItemSelBkgnd", m_crItemSelBg, FALSE)
            ATTR_COLOR(L"colorItemText", m_crItemText, FALSE)
            ATTR_COLOR(L"colorItemSelText", m_crItemSelText, FALSE)
            ATTR_COLOR(L"colorItemSelParentText", m_crItemSelParentText, FALSE)
            ATTR_BOOL(L"hasLines", m_bHasLines, TRUE)
        SOUI_ATTRS_END()





        , m_crItemSelBg(RGBA(0, 0, 136, 255))
        , m_crItemText(RGBA(0, 0, 0, 255))
        , m_crItemSelText(RGBA(255, 255, 255, 255))
        , m_crItemSelParentText(RGBA(255, 255, 255, 255))
        , m_nVisibleItems(0)
        , m_nContentWidth(0)
        , m_bCheckBox(FALSE)




            if (m_hSelItem)
            {
                bool bFindParent = false;
                HSTREEITEM hParent = GetParentItem(m_hSelItem);
                while (hParent && !bFindParent)
                {
                    if (hItem == hParent)
                    {
                        bFindParent = true;
                        break;
                    }
                    hParent = GetParentItem(hParent);
                }
                if (CR_INVALID != m_crItemSelParentText && bFindParent)
                {
                    bTextColorChanged = TRUE;
                    crOldText = pRT->SetTextColor(m_crItemSelParentText);
                }
            }
        }
        if (pItem->bHasChildren && STVIMask_Toggle == (m_uItemMask & STVIMask_Toggle) && !m_bHasLines)

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|SOUI官方论坛

    GMT+8, 2026-4-17 16:14 , Processed in 0.283687 second(s), 24 queries .

    Powered by Discuz! X3.5

    © 2001-2025 Discuz! Team.

    快速回复 返回顶部 返回列表