关于CTreeCtrl的重画问题.

天下第一好大人 2006-04-18 05:15:38
映射NM_CUSTOMDRAW消息,然后

void CTreeCtrlEx::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
static CRect rcItem;
static int nItemState;

LPNMTVCUSTOMDRAW pCustomDraw = (LPNMTVCUSTOMDRAW)pNMHDR;
switch (pCustomDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
// Need to process this case and set pResult to CDRF_NOTIFYITEMDRAW,
// otherwise parent will never receive CDDS_ITEMPREPAINT notification. (GGH)
*pResult = CDRF_NOTIFYITEMDRAW;

// reposuition the viewport so the TreeCtrl DefWindowProc doesn't draw to viewport 0/0
//::SetViewportOrgEx(pCustomDraw->nmcd.hdc, /*m_nOffset*/0, 0, NULL);
break;

case CDDS_ITEMPREPAINT:
// set the background and foregroundcolor of the item to the background, so you don't see the default drawing of the text
//get item state(focus,selected..), because it will be drawn of us
nItemState = pCustomDraw->nmcd.uItemState;

pCustomDraw->nmcd.uItemState &= ~CDIS_FOCUS;
//pCustomDraw->clrText = m_colHilightText;
// remember the drawing rectangle of the item so we can draw it ourselves
GetItemRect((HTREEITEM) pCustomDraw->nmcd.dwItemSpec, &rcItem, TRUE);
*pResult = CDRF_NOTIFYPOSTPAINT;
break;

case CDDS_ITEMPOSTPAINT:
DrawTreeItem(nItemState, rcItem, pCustomDraw->nmcd.hdc, (HTREEITEM) pCustomDraw->nmcd.dwItemSpec);
break;
default:
*pResult = CDRF_DODEFAULT;
}
}

void CTreeCtrlEx::DrawTreeItem(int nItemState, CRect rcItem, HDC hdc, HTREEITEM hItem)
{
CEdit pEdit;
pEdit.Create(//ES_MULTILINE|ES_WANTRETURN|ES_AUTOVSCROLL|
WS_CHILD|WS_VISIBLE//| WS_HSCROLL | WS_VSCROLL
|WS_TABSTOP |WS_CLIPCHILDREN,
rcItem,
this,
61012);
}

也就是我想用cedit代替原来默认的子项,为了防止闪烁,我就在OnEraseBkgnd(CDC* pDC)中直接
return TRUE;

可是现在那些cedit可以弹出却收不回去了,估计是没擦除背景的原因吧.

怎么能既不闪烁又能够收回去呢?
...全文
162 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ripyu 2006-04-18
  • 打赏
  • 举报
回复
你的edit没有销毁啊

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧