void CGraphListDlg::OnGraphEdit() { int nItem = m_wndList.GetNextItem( -1, LVNI_SELECTED ); if ( nItem < 0 ) return; CGraphItemDlg dlg( this, (CGraphItem*)m_wndList.GetItemData( nItem ) ); if ( dlg.DoModal() == IDOK ) { CLiveItem* pLive = PrepareItem( dlg.m_pItem ); pLive->Update( &m_wndList, nItem, LIST_COLUMNS ); delete pLive; SetModified(); } }
void CLiveList::Apply(CListCtrl* pCtrl, BOOL bSort) { ASSERT_VALID( this ); CQuickLock oLock( m_pSection ); BOOL bModified = FALSE; for ( int nItem = 0 ; nItem < pCtrl->GetItemCount() ; nItem++ ) { DWORD nParam = (DWORD)pCtrl->GetItemData( nItem ); CLiveItem* pItem; if ( m_pItems.Lookup( nParam, pItem ) ) { ASSERT_VALID( pItem ); if ( pItem->Update( pCtrl, nItem, m_nColumns ) ) bModified = TRUE; delete pItem; m_pItems.RemoveKey( nParam ); } else { pCtrl->DeleteItem( nItem-- ); bModified = TRUE; } } int nCount = pCtrl->GetItemCount(); for ( POSITION pos = m_pItems.GetStartPosition() ; pos ; ) { CLiveItem* pItem; DWORD_PTR nParam; m_pItems.GetNextAssoc( pos, nParam, pItem ); ASSERT_VALID( pItem ); pItem->Add( pCtrl, nCount++, m_nColumns ); bModified = TRUE; delete pItem; } m_pItems.RemoveAll(); if ( bModified && bSort ) Sort( pCtrl, -1 ); }
void CLiveList::Apply(CListCtrl* pCtrl, BOOL bSort) { ASSERT_VALID( this ); BOOL bModified = FALSE; int nCount = pCtrl->GetItemCount(); // Start flicker workaround for VS2012 //#if defined(_MSC_VER) && (_MSC_VER >= 1700) // #ifdef _USING_V110_SDK71_ #if defined(_MSC_PLATFORM_TOOLSET) && (_MSC_PLATFORM_TOOLSET >= 110) // Custom define pCtrl->SendMessage( WM_SETREDRAW, FALSE ); const int nSelected = pCtrl->GetNextItem( -1, LVNI_SELECTED ); #endif CQuickLock oLock( m_pSection ); for ( int nItem = 0 ; nItem < nCount ; nItem++ ) { DWORD nParam = (DWORD)pCtrl->GetItemData( nItem ); CLiveItem* pItem; if ( m_pItems.Lookup( nParam, pItem ) ) { ASSERT_VALID( pItem ); if ( pItem->Update( pCtrl, nItem, m_nColumns ) ) bModified = TRUE; delete pItem; m_pItems.RemoveKey( nParam ); } else { pCtrl->DeleteItem( nItem-- ); bModified = TRUE; nCount--; } } nCount = pCtrl->GetItemCount(); // ToDo: Is this double-check needed? for ( POSITION pos = m_pItems.GetStartPosition() ; pos ; ) { CLiveItem* pItem; DWORD_PTR nParam; m_pItems.GetNextAssoc( pos, nParam, pItem ); ASSERT_VALID( pItem ); pItem->Add( pCtrl, nCount++, m_nColumns ); bModified = TRUE; delete pItem; } m_pItems.RemoveAll(); if ( bModified && bSort ) Sort( pCtrl, -1 ); // End flicker workaround for VS2012 //#if defined(_MSC_VER) && (_MSC_VER >= 1700) // #ifdef _USING_V110_SDK71_ #if defined(_MSC_PLATFORM_TOOLSET) && (_MSC_PLATFORM_TOOLSET >= 110) // Custom define pCtrl->SendMessage( WM_SETREDRAW, TRUE ); if ( nSelected >= 0 ) { pCtrl->SetItemState( nSelected, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED ); pCtrl->SetSelectionMark( nSelected ); } #endif }