Click here to Skip to main content
15,919,245 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionLVN_ITEMCHANGING Pin
YaronNir10-May-06 4:32
YaronNir10-May-06 4:32 
Hi All,

I have a window that on the left side it has a list control, and selecting an item in that list , switch between child dialogs (same as in all property pages).


my problem is that before i jump into the new page i validate the current page and if it is not invalid i show a message. here i want to prevent the list from jumping to the new selected item.

here is the code i use:

BEGIN_MESSAGE_MAP(...)
ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST,OnListItemChanged)
ON_NOTIFY(LVN_ITEMCHANGING,IDC_LIST,OnListItemChanging)
END_MESSAGE_MAP(...)

void CMyWnd::OnListItemChanged(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLISTVIEW *pState = (NMLISTVIEW *)pNMHDR;

//... do whatever

*pResult = 0;
}

void CMyWnd::OnListItemChanging(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pState = (NM_LISTVIEW*)pNMHDR;

if (pState->iItem == m_iCurrentItem)
{
if (!ValidatePage(...)
{
*pResult = TRUE;
return;
}
}

*pResult = FALSE;
}

the problem is that the OnTopicListItemChanging is being called twice so i get twice a message box.....i tried to prevent that using a static bool variable, but didn't do me good...

any suggestions?

thanks in advanced
Yaron



Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp

don't forget to vote Smile | :)


-- modified at 10:33 Wednesday 10th May, 2006
AnswerRe: LVN_ITEMCHANGING Pin
David Crow10-May-06 6:17
David Crow10-May-06 6:17 
GeneralRe: LVN_ITEMCHANGING Pin
YaronNir10-May-06 10:00
YaronNir10-May-06 10:00 
Questionsrvany Problems Pin
steff.k@gmx.net10-May-06 4:16
steff.k@gmx.net10-May-06 4:16 
AnswerRe: srvany Problems Pin
David Crow10-May-06 6:13
David Crow10-May-06 6:13 
GeneralRe: srvany Problems Pin
steff.k@gmx.net10-May-06 21:03
steff.k@gmx.net10-May-06 21:03 
Questionhow to stop the action of one button by pushing another button Pin
joy2110-May-06 3:55
joy2110-May-06 3:55 
AnswerRe: how to stop the action of one button by pushing another button Pin
Cedric Moonen10-May-06 4:01
Cedric Moonen10-May-06 4:01 
QuestionRe: how to stop the action of one button by pushing another button Pin
joy2110-May-06 4:31
joy2110-May-06 4:31 
AnswerRe: how to stop the action of one button by pushing another button Pin
Cedric Moonen10-May-06 4:36
Cedric Moonen10-May-06 4:36 
AnswerRe: how to stop the action of one button by pushing another button Pin
Chris Losinger10-May-06 4:02
professionalChris Losinger10-May-06 4:02 
QuestionMsgsrv.exe Pin
Aryan S10-May-06 3:18
Aryan S10-May-06 3:18 
AnswerRe: Msgsrv.exe Pin
David Crow10-May-06 3:49
David Crow10-May-06 3:49 
AnswerRe: Msgsrv.exe Pin
Steffen Lange10-May-06 5:46
Steffen Lange10-May-06 5:46 
QuestionMetafile Pin
submit-CD10-May-06 3:15
submit-CD10-May-06 3:15 
AnswerRe: Metafile Pin
Chris Losinger10-May-06 3:52
professionalChris Losinger10-May-06 3:52 
GeneralRe: Metafile Pin
submit-CD10-May-06 4:23
submit-CD10-May-06 4:23 
GeneralRe: Metafile Pin
Chris Losinger10-May-06 4:47
professionalChris Losinger10-May-06 4:47 
QuestionShortcuts... Pin
Smith#10-May-06 3:13
Smith#10-May-06 3:13 
AnswerRe: Shortcuts... Pin
Hamid_RT10-May-06 3:25
Hamid_RT10-May-06 3:25 
QuestionHow to make Win32 dll depend on mfc dll? Pin
Kurnia Kosasi10-May-06 3:06
Kurnia Kosasi10-May-06 3:06 
AnswerRe: How to make Win32 dll depend on mfc dll? Pin
Andrew Hain10-May-06 3:30
Andrew Hain10-May-06 3:30 
GeneralRe: How to make Win32 dll depend on mfc dll? Pin
Andrew Hain10-May-06 3:33
Andrew Hain10-May-06 3:33 
AnswerRe: How to make Win32 dll depend on mfc dll? Pin
Kurnia Kosasi10-May-06 4:05
Kurnia Kosasi10-May-06 4:05 
QuestionSAFEARRAY question Pin
scoroop10-May-06 3:01
scoroop10-May-06 3:01 

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.