Click here to Skip to main content
16,004,991 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: if-Statement getting me crazy Pin
User 665816-Feb-04 11:48
User 665816-Feb-04 11:48 
GeneralRe: if-Statement getting me crazy Pin
Andy Brummer16-Feb-04 11:49
sitebuilderAndy Brummer16-Feb-04 11:49 
GeneralRe: if-Statement getting me crazy Pin
Maxwell Chen16-Feb-04 18:09
Maxwell Chen16-Feb-04 18:09 
General[OT]: 2 new questions Pin
User 665816-Feb-04 12:06
User 665816-Feb-04 12:06 
GeneralRe: [OT]: 2 new questions Pin
Christian Graus16-Feb-04 12:45
protectorChristian Graus16-Feb-04 12:45 
GeneralRe: if-Statement getting me crazy Pin
Toni7816-Feb-04 15:23
Toni7816-Feb-04 15:23 
GeneralRe: if-Statement getting me crazy Pin
Maxwell Chen16-Feb-04 18:02
Maxwell Chen16-Feb-04 18:02 
Generallist ctrl help-- if new item selected, validate old, and keep old if validation fails Pin
hiseldl16-Feb-04 8:40
hiseldl16-Feb-04 8:40 
I have a CListCtrl in a CFormView that represents objects. In the form view I have controls that represent data of the selected object.

When a new object is selected in the list, I need to:
1. validate the data
2. if the data is not valid, keep the original list item selected, and do not select the new item.
3. if the data is valid, then show the data of the new object.

I have added OnItemchangingX and OnItemchangedX for the list control to my form view class.

void CAddonView::OnItemchangingX(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	BOOL bValidateSuccessful = validate();

	if (!bValidateSuccessful) {

	--------------------------------------------------
	...what do I do here to keep the old item selected
	...and keep the new one from getting selected?
	--------------------------------------------------

	}
}

void CAddonView::OnItemchangedX(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	int iSelItem = m_listAP.GetNextItem(-1, LVNI_ALL | LVNI_SELECTED);
	if (iSelItem != -1 && pNMListView->uNewState & LVIS_SELECTED)
	{
	...load data of newly selected item...
	}
}
What do I need to do to keep the old selection if the validation fails?

Thanks.

--
David Hisel
Internet Business Software
GeneralRe: list ctrl help-- if new item selected, validate old, and keep old if validation fails Pin
SolarPanel+16-Feb-04 12:31
SolarPanel+16-Feb-04 12:31 
GeneralImport a "C" function that returns a struct... Pin
sammyh16-Feb-04 8:25
sammyh16-Feb-04 8:25 
GeneralRe: Import a "C" function that returns a struct... Pin
Robert A. T. Káldy17-Feb-04 0:42
Robert A. T. Káldy17-Feb-04 0:42 
Generallocking toolbars in place ... Pin
Maximilien16-Feb-04 7:47
Maximilien16-Feb-04 7:47 
GeneralRe: locking toolbars in place ... Pin
David Crow16-Feb-04 7:59
David Crow16-Feb-04 7:59 
GeneralScientific Notation Pin
Walt_S16-Feb-04 6:28
Walt_S16-Feb-04 6:28 
GeneralRe: Scientific Notation Pin
David Crow16-Feb-04 7:22
David Crow16-Feb-04 7:22 
GeneralRe: Scientific Notation Pin
Walt_S16-Feb-04 7:27
Walt_S16-Feb-04 7:27 
QuestionHow to access and Modify the Child Window Menu Pin
Omar Alvi16-Feb-04 6:20
Omar Alvi16-Feb-04 6:20 
AnswerRe: How to access and Modify the Child Window Menu Pin
Antti Keskinen16-Feb-04 9:49
Antti Keskinen16-Feb-04 9:49 
GeneralRe: How to access and Modify the Child Window Menu Pin
Omar Alvi16-Feb-04 18:14
Omar Alvi16-Feb-04 18:14 
GeneralRe: How to access and Modify the Child Window Menu Pin
Antti Keskinen16-Feb-04 22:01
Antti Keskinen16-Feb-04 22:01 
GeneralToolBar problem Pin
Deian16-Feb-04 6:03
Deian16-Feb-04 6:03 
GeneralRe: ToolBar problem Pin
LunaticFringe16-Feb-04 7:47
LunaticFringe16-Feb-04 7:47 
GeneralRe: ToolBar problem Pin
Deian16-Feb-04 7:54
Deian16-Feb-04 7:54 
GeneralGDI+ Pin
Prakash Nadar16-Feb-04 5:40
Prakash Nadar16-Feb-04 5:40 
GeneralRe: GDI+ Pin
Steve S16-Feb-04 6:19
Steve S16-Feb-04 6:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.