thanks
Replythanks a lot. this is exactly what I want.
ReplyFor correct background color change this line memDC.SetBkColor( GetSysColor( COLOR_WINDOW ) ); to memDC.SetBkColor( GetBkColor() );
ReplyI found this code very helpful. Bit tricky, but works fine. Since there is no "SetItemColor" support from MFC for TreeCtrl, this solution with "drawing over item" is quite smart:-) Well done!
ReplyI found this code very helpful. Bit tricky, but works fine. Since there is no "SetItemColor" support from MFC for TreeCtrl, this solution with "drawing over item" is quite smart:-) Well done!
Replyit's perfect
ReplyOriginally posted by: talai
BOOL CTreeCtrlX::DeleteAllItems()
{
m_mapColorFont.RemoveAll();
return CTreeCtrl::DeleteAllItems();
}
Reply
Originally posted by: Ed
if ( !(GetItemState( hItem, selflag ) & selflag )
caused some problems if I had an else that relied on the Lookup function as well. So I just switched the two around and that seemed to fix my problem:
if ( m_mapColorFont.Lookup( hItem, cf )
I found that the if statement:
&& m_mapColorFont.Lookup( hItem, cf ))
&& !(GetItemState( hItem, selflag ) & selflag ))
Reply
Originally posted by: jared007
Hi, Im pretty stumped here....
I have a control, just as this example, w/ buttons and custom text fonts. How can I gain reference to the height of the button (+,-) in the control, so I can draw the text the same height as it, and vertically align it with the button.
Right now, when I change the font, the text often appears vertically aligned above the button. How far it is drawn above the button depends on the font type an weight, but I would guess it ranges from 1 - 3 pixels.
Reply
Originally posted by: Rudy Kappert
case WM_NOTIFY:
NMTVCUSTOMDRAW nvcustom;
..
..
nvcustom=*((NMTVCUSTOMDRAW*)lParam);
switch(nvcustom.nmcd.hdr.code)
{
case NM_CUSTOMDRAW:
switch(nvcustom.nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
switch(nvcustom.iLevel)
{
case 0: // root item
SetTextColor(nvcustom.nmcd.hdc,RGB(0,0,0));
break;
case 1: // child of root item
SetTextColor(nvcustom.nmcd.hdc,RGB(0,0,0));
break;
}
return CDRF_NEWFONT;
}
}