void CFeedIcoItemListCtrl::OnLvnHotTrack(NMHDR *pNMHDR, LRESULT *pResult) { // vista+ 系统的经典主题和vista-系统的 必须要加此消息 if (thePrefs.GetWindowsVersion() >= _WINVER_VISTA_ && IsThemeEnabled()) return; LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR); // TODO: Add your control notification handler code here *pResult = 0; int nCurrentHotItemIndex = GetHotItem(); if (nCurrentHotItemIndex == m_nLastHotItemIndex) return; if (-1 != nCurrentHotItemIndex) {// move into the hot item m_nLastHotItemIndex = nCurrentHotItemIndex; } else {// move out of the hot item nCurrentHotItemIndex = m_nLastHotItemIndex; m_nLastHotItemIndex = -1; } CRect itemRect(0,0,0,0); GetItemRect(nCurrentHotItemIndex, &itemRect, LVIR_BOUNDS); InvalidateRect(&itemRect); }
void CListCtrl_Sortable::SetSortArrow(int colIndex, bool ascending) { if (IsThemeEnabled()) { #if (_WIN32_WINNT >= 0x501) for(int i = 0; i < GetHeaderCtrl()->GetItemCount(); ++i) { HDITEM hditem = {0}; hditem.mask = HDI_FORMAT; VERIFY( GetHeaderCtrl()->GetItem( i, &hditem ) ); hditem.fmt &= ~(HDF_SORTDOWN|HDF_SORTUP); if (i == colIndex) { hditem.fmt |= ascending ? HDF_SORTDOWN : HDF_SORTUP; } VERIFY( CListCtrl::GetHeaderCtrl()->SetItem( i, &hditem ) ); } #endif } else { UINT bitmapID = m_Ascending ? IDB_DOWNARROW : IDB_UPARROW; for(int i = 0; i < GetHeaderCtrl()->GetItemCount(); ++i) { HDITEM hditem = {0}; hditem.mask = HDI_BITMAP | HDI_FORMAT; VERIFY( GetHeaderCtrl()->GetItem( i, &hditem ) ); if (hditem.fmt & HDF_BITMAP && hditem.fmt & HDF_BITMAP_ON_RIGHT) { if (hditem.hbm) { DeleteObject(hditem.hbm); hditem.hbm = NULL; } hditem.fmt &= ~(HDF_BITMAP|HDF_BITMAP_ON_RIGHT); VERIFY( CListCtrl::GetHeaderCtrl()->SetItem( i, &hditem ) ); } if (i == colIndex) { hditem.fmt |= HDF_BITMAP|HDF_BITMAP_ON_RIGHT; hditem.hbm = (HBITMAP)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(bitmapID), IMAGE_BITMAP, 0,0, LR_LOADMAP3DCOLORS); VERIFY( hditem.hbm!=NULL ); VERIFY( CListCtrl::GetHeaderCtrl()->SetItem( i, &hditem ) ); } } } }