我创建了一个带有树控件的 Outlook 栏,并希望让它自动调整大小以始终完全显示树控件的文本。理想情况下,图片中的边框会移动,以便“医疗保健商品”完全可见。
newDimbar 是在 CMainFrame 中创建的 CMFCOutlookBar 对象。
我试过拉伸它:
void CTreeDrill::OnTvnItemexpanded(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
HTREEITEM hItem = pNMTreeView->itemNew.hItem;
RECT treeRect;
GetItemRect(GetChildItem(hItem), &treeRect, FALSE);
CMainFrame *pMain = (CMainFrame*)AfxGetMainWnd();
int iStretch = treeRect.right;
pMain->m_ctlNewDimBar.StretchPane(iStretch, FALSE);
EnsureVisible(GetChildItem(hItem));
}
并使用移动:
void CTreeDrill::OnTvnItemexpanded(NMHDR *pNMHDR, LRESULT *pResult)
{
RECT treeRect;
RECT newRect;
RECT dimRect;
GetItemRect(GetChildItem(hItem), &treeRect, FALSE);
CMainFrame *pMain = (CMainFrame*)AfxGetMainWnd();
pMain->m_ctlNewDimBar.GetWindowRect(&dimRect);
newRect = dimRect;
newRect.right = treeRect.right;
pMain->m_ctlNewDimBar.MoveWindow(newRect);
EnsureVisible(GetChildItem(hItem));
}
没有运气。我错过了什么?