2 yumorende yumorende 于 2014.09.09 11:18 提问

NM_CUSTROMDRAW消息用于TOOLBAR如何设置高亮时按钮文本

在TOOLBAR中设置 NMTBCUSTOMDRAW结构体,以改变文本的颜色, 我已经成功改变TOOLBAR文本颜色, 但是 如何设置高亮文本 那就一头雾水 了

void MyToolBar::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) //on draw item
{

   NMTBCUSTOMDRAW* pLVCD = reinterpret_cast<NMTBCUSTOMDRAW*> (pNMHDR);

   DWORD DW = *pResult;
   *pResult = 0;    // First thing - check the draw stage(阶段). If it's the control's prepaint(preprint)

    COLORREF crText; 
    COLORREF crHighText;
   if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )           //before a painting cycle begin 
   {
       *pResult = CDRF_NOTIFYITEMDRAW;                    //自己完成绘制
   }
   else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )          //before an item is draw
   {
       // This is the prepaint stage for an item. Here's where we set the
       // item's text color. Our return value will tell Windows to draw the
       // item itself, but it will use the new color we set here.
       // We'll cycle the colors through red, green, and light blue.

        crText = RGB(255,0,0);
        crHighText = RGB(0, 255, 0);
        pLVCD->clrText = crText;        // Tell Windows to paint the control itself.
        pLVCD->clrTextHighlight = crHighText;
        *pResult = CDRF_NEWFONT;

   }

}

如上, 我设置了,但是鼠标移动到TOOLBAR控件按钮上时, 文本颜色没有变化啊~

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!