这个问题是related to this one。
在CDockablePane派生类中,我有一个CTreeCtrl成员,我在OnCreate()中添加了一个ToolTip:
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中设置为CRect
的{{1}}成员。这真是太丑了。
每当(0, 0, 10000, 10000)
的尺寸发生变化时,我想调整工具的矩形
所以我在m_tree
中尝试了一些东西,但没有一个有效:
CMyPane::OnSize()
然后修改m_pToolTip->GetToolInfo()
的rect成员,然后调用CToolInfo
SetToolInfo()
这是怎么回事?
答案 0 :(得分:3)
我知道除了在DelTool
处理程序中再次调用AddTool
然后再调用OnSize
之外,别无其他办法:
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);
}
}
答案 1 :(得分:0)
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;
}