2015-05-30 1 views

ответ

0
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 .... 
}