Beispiel #1
0
LRESULT AutoSearchFrame::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
	//use a removelist, the selection position will change when removing multiple.
	AutoSearchList removelist;

	int i = -1;
	while ((i = ctrlAutoSearch.GetNextItem(i, LVNI_SELECTED)) != -1) {
		removelist.push_back(ctrlAutoSearch.getItemData(i)->asItem);
	}

	if (WinUtil::MessageBoxConfirm(SettingsManager::CONFIRM_AS_REMOVAL, TSTRING(REALLY_REMOVE))) {
		for (auto a = removelist.begin(); a != removelist.end(); ++a)
			AutoSearchManager::getInstance()->removeAutoSearch(*a);
	}
	return 0;
}
LRESULT AutoSearchFrame::onMoveDown(WORD , WORD , HWND , BOOL& ) {
	int i = ctrlAutoSearch.GetSelectedIndex();
	if(i != -1 && i != (ctrlAutoSearch.GetItemCount()-1) ) {
		//swap and reload list, not the best solution :P
		ctrlAutoSearch.SetRedraw(FALSE);
		AutoSearchManager::getInstance()->moveAutoSearchDown(i);
		ctrlAutoSearch.DeleteAllItems();

		AutoSearchList lst = AutoSearchManager::getInstance()->getSearchItems();
		for(auto j = lst.begin(); j != lst.end(); ++j) {
			const AutoSearchPtr as = *j;	
			addEntry(as, ctrlAutoSearch.GetItemCount());
		}
		ctrlAutoSearch.SetRedraw(TRUE);
		ctrlAutoSearch.Invalidate();
		ctrlAutoSearch.SetItemState(i+1, LVIS_SELECTED, LVIS_SELECTED);
		ctrlAutoSearch.EnsureVisible(i+1, FALSE);

	}
	return 0;
}