如何修改CToolTipCtrl的工具矩形?
这个问题与此相关。
在 CDockablePane 派生类中,我有一个 CTreeCtrl 成员,我在 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
是 CTor 中设置为 (0, 0, 10000, 10000)
的 CRect
成员。 这实在是太难看了。
我想在 m_tree
的大小发生变化时调整工具的矩形。
所以我在 CMyPane::OnSize()
中尝试了一些东西,但没有一个起作用:
- 调用
m_pToolTip->GetToolInfo()
然后修改CToolInfo
> 的 rect 成员,然后调用SetToolInfo()
- 调用
m_pToolTip->SetToolRect()
这是如何完成的?
This question is related to this one.
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;
}
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.
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:
- Calling
m_pToolTip->GetToolInfo()
then modify theCToolInfo
's rect member, then callingSetToolInfo()
- Calling
m_pToolTip->SetToolRect()
How is it meant to be done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道除了在
OnSize
处理程序中再次调用DelTool
然后再次调用AddTool
之外,没有其他方法可以做到这一点:I know no other way to do this other than calling
DelTool
thenAddTool
again in yourOnSize
handler: