如何修改CToolTipCtrl的工具矩形? [英] How to modify the tool rect of a CToolTipCtrl?

查看:186
本文介绍了如何修改CToolTipCtrl的工具矩形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题是与此相关的

This question is related to this one.

在CDockablePane派生类中,我有一个CTreeCtrl成员,在OnCreate()中添加一个ToolTip:

In a CDockablePane derived class I have a CTreeCtrl member for which I add a ToolTip in OnCreate():

int CMyPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CDockablePane::OnCreate(lpCreateStruct) == -1)
        return -1;

    const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
        TVS_CHECKBOXES | TVS_DISABLEDRAGDROP | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT |
        TVS_INFOTIP | TVS_NOHSCROLL | TVS_SHOWSELALWAYS;

    if(!m_tree.Create(dwStyle, m_treeRect, this, TREECTRL_ID) ) { return -1; }

    m_pToolTip->AddTool(&m_tree, LPSTR_TEXTCALLBACK, &m_treeRect, TREECTRL_ID);
    m_tree.SetToolTips(m_pToolTip);


    return 0;
}



我必须使用所有可选参数调用AddTool值不能与CDockablePane一起使用。

m_treeRect 是一个 CRect 成员设置为(0,0,10000,10000)。这真的很丑陋。

I have to call AddTool() with all of the optional parameters because the default values won't work with CDockablePane.
m_treeRect is a CRect member set to (0, 0, 10000, 10000) in the CTor. This is really ugly.

每当 m_tree 的大小改变时,我想调整工具的矩形。 />
所以我尝试了一些东西在 CMyPane :: OnSize()但没有一个工作:

I would like to adjust the tool's rectangle whenever m_tree's size changes.
So I tried some stuff in CMyPane::OnSize() but none of it worked:


  • 调用 m_pToolTip-> GetToolInfo(),然后修改 CToolInfo 的rect然后调用 SetToolInfo()

  • 调用 m_pToolTip-> SetToolRect()

  • Calling m_pToolTip->GetToolInfo() then modify the CToolInfo's rect member, then calling SetToolInfo()
  • Calling m_pToolTip->SetToolRect()

如何实现?

推荐答案

除了调用 DelTool 然后 AddTool 你的 OnSize 处理程序:

I know no other way to do this other than calling DelTool then AddTool again in your OnSize handler:

void CMyPane::OnSize(UINT nType, int cx, int cy)
{
    CDockablePane::OnSize(nType, cx, cy);

    if (m_pToolTip != NULL)
    {
        m_pToolTip->DelTool(&m_tree, TREECTRL_ID);

        CRect treeRect;
        m_tree.GetClientRect(treeRect);

        m_pToolTip->AddTool(&m_tree, LPSTR_TEXTCALLBACK, &treeRect, TREECTRL_ID);
    }
}

这篇关于如何修改CToolTipCtrl的工具矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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