首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CListBox热光跟踪

CListBox热光跟踪
EN

Stack Overflow用户
提问于 2015-05-30 16:28:07
回答 1查看 123关注 0票数 0

我使用DrawItem ()重绘了CListBoxods_hotlight在win7/win8中不起作用。如何进行此CListBox hotlight跟踪?

EN

回答 1

Stack Overflow用户

发布于 2015-05-31 01:57:21

代码语言:javascript
复制
OK ,I solved this now .... ,Code posted below :

extern "C" WINUSERAPI BOOL WINAPI TrackMouseEvent (LPTRACKMOUSEEVENT lpEventTrack);

    void CListBoxCS::OnMouseMove(UINT nFlags, CPoint point) 
    {
        // TODO: Add your message handler code here and/or call default
        TRACKMOUSEEVENT tme;
        tme.cbSize      = sizeof(TRACKMOUSEEVENT);
        tme.dwFlags     = TME_HOVER | TME_LEAVE;
        tme.dwHoverTime = HOVER_DEFAULT;
        tme.hwndTrack   = m_hWnd;
        tme.dwHoverTime = 1;
        TrackMouseEvent (&tme);

        BOOL        bOut = TRUE;
        short       index;

        index = (short) ItemFromPoint (point,bOut);
        if (FALSE == bOut) {
            if (m_ihot != index) {
                m_ihot = index;
                //printf ("index = %d \n",m_ihot);
                Invalidate (FALSE);
            }
        } else {
            //printf ( "out \n" );
        }
    }

    void CListBoxCS::OnMouseLeave (void) 
    {
        //printf ( "mouse leave \n" );
        m_ihot = -1;
    }

void CListBoxCS::DrawItem (LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
    // some judgements here .....

    // some preparations 

    // hot light code ...
    if ((act & ODA_SELECT) || (act & ODA_DRAWENTIRE)) {
        if (lpDIS->itemState & ODS_SELECTED) { 
            dc.FillSolidRect (&lpDIS->rcItem,(RGB (209, 232, 255)));
        } else { 
            dc.FillSolidRect (&lpDIS->rcItem,(RGB (230, 230, 230)));
        } 

        if (m_ihot == lpDrawItemStruct->itemID) {
            dc.FillSolidRect (&lpDIS->rcItem,(RGB (229, 243, 251)));
        }
     }
     // something U like to do ....
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30544000

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档