My question is:
If the data that I test when I handle the TVN_SELCHANGING
message is not valid, how can I stop the TVN_SELCHANGED
from happening (make the tree item with the bad data stay
as the selected item), and set the focus to the control with bad
data?
Thanks in advance,
Adam Christensen
void CTreeDlg::OnSelChangingTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
HTREEITEM hItemOld = pNMTreeView->itemOld.hItem;
if( hItemOld )
{
if( m_tree.GetItemData( hItemOld ) == 1010 )
m_fInvalidItem = TRUE;
else
m_fInvalidItem = FALSE;
}
*pResult = 0;
}
void CTreeDlg::OnSelchangedTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
if( m_fInvalidItem )
{
m_tree.SelectItem( pNMTreeView->itemOld.hItem );
*pResult = 0;
return;
}
if( pNMTreeView->itemNew.hItem )
{
m_lDisplay = m_tree.GetItemData(
pNMTreeView->itemNew.hItem );
UpdateData(FALSE);
}
*pResult = 0;
}
This is a simple basic dialog I threw together to see if I could stop
that message. The above works, but it has a horrible side effect.
Lets say I have the 3rd item selected...I change the data member to be
1010 like I check for above. I then move to another...it finds out
that the 3rd Item is invalid so it sets m_fInvalidItem to TRUE. So
here is what the tree control does...draw the selection around the
OTHER item I selected and then instantly switches it back to the 3rd
Item. Not exactly a nice thing...but it doesn't let them come off the
3rd until they fix the data.
Sorry I couldn't help more...
Justin
Remove .---- from address to mail...
Spam has just gotten too bad.
Hi Adam,
>>>>
My question is:
If the data that I test when I handle the TVN_SELCHANGING
message is not valid, how can I stop the TVN_SELCHANGED
from happening (make the tree item with the bad data stay
as the selected item), and set the focus to the control with bad
data?
>>>>
You can stop the TVN_SELCHANGED event being triggered, by assigning TRUE to
the second parameter of your TVN_SELCHANGING event's procedure.
It's a LRESULT value.
Aditi Corp was formerly known as NetQuest Inc.
P.S. : Worried about response times to your queries?
Check out our FREE technical support service at http://www.aditi.com/nntp.htm
OR just click on the attached link
begin 600 link.url
M6TEN=&5R;F5T4VAO<G1C=71=#0I54DP]:'1T<#HO+W=W=RYA9&ET:2YC;VTO
*;FYT<"YH=&T-"FAO
`
End