newntui/activex/queriescombo/src/queriescomboctl.cpp
//-----------------------------------------------------------------------------------------
// This method re-fills complete queries list trying to re-set old selections.
//-----------------------------------------------------------------------------------------
This method re-fills complete queries list trying to re-set old selections.
This method re - fills complete queries list trying to re - set old selections .
void CQueriesComboCtrl::Update()  {
CList<CString,CString&> selection;
	for(register i=0;i<m_ListView.GetItemCount();i++) {
		if(m_ListView.GetItemState(i,LVIS_SELECTED)!=0) {
			CString lookFor;
			lookFor=m_ListView.GetItemText(i,0);
			selection.AddTail(lookFor);
		}
	}
	FillList();
	POSITION pos;
    LV_FINDINFO findInfo;
	findInfo.flags=LVFI_STRING;
	pos=selection.GetHeadPosition();
	while(pos!=NULL) {
	   findInfo.psz=selection.GetAt(pos); 
	   int index = m_ListView.FindItem(&findInfo);
	   if(index!=-1) {
	       m_ListView.SetItemState(index,LVIS_SELECTED,LVIS_SELECTED);
	   }
	   selection.GetNext(pos);
	}
}
void CQueriesComboCtrl :: Update ( ) { CList < CString , CString & > selection ; for ( register i = 0 ; i < m_ListView . GetItemCount ( ) ; i ++ ) { if ( m_ListView . GetItemState ( i , LVIS_SELECTED ) != 0 ) { CString lookFor ; lookFor = m_ListView . GetItemText ( i , 0 ) ; selection . AddTail ( lookFor ) ; } } FillList ( ) ; POSITION pos ; LV_FINDINFO findInfo ; findInfo . flags = LVFI_STRING ; pos = selection . GetHeadPosition ( ) ; while ( pos != NULL ) { findInfo . psz = selection . GetAt ( pos ) ; int index = m_ListView . FindItem ( & findInfo ) ; if ( index != -1 ) { m_ListView . SetItemState ( index , LVIS_SELECTED , LVIS_SELECTED ) ; } selection . GetNext ( pos ) ; } }
This method re-fills complete queries list trying to re-set old selections.
This method re - fills complete queries list trying to re - set old selections .
// Collecting all selected items names in the selection array // Filling list with the new values // Restoring selections where possible // And if it is present // Selecting this item