|
My code is like this, why i see the ImageIndex as well.
Once i click the checkbox, I like to display only the StateImage
And also, if i use
ht.Contains(htOnStateIcon)
Never hit this.
ps. If i use ImageIndex instead of StateIndex, it shows the single icon but
it's not reflect the change properly.
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
AnsiString s;
TTreeNode *pNode = NULL;
TTreeNode *pAddToNode = NULL;
TTreeNode *pChildNode;
for ( int i = 0; i < 20; i++ )
{
s = AnsiString( "test node") + AnsiString(i);
pNode = tv->Items->AddObject( NULL,s.c_str() , (TObject *)0xffff );
pNode->StateIndex = 2;//checked icon..
pAddToNode = pNode;
for( int j=0;j<3 ;j++ )
{
pNode = tv->Items->AddChildObject( pAddToNode ,s.c_str() , (TObject *)0xffff );
pNode->StateIndex = 2;
}
}
}
void __fastcall TForm1::tvMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if ( Button == mbLeft )
{
TTreeNode *pNode = ((TTreeView*)Sender)->GetNodeAt(X, Y);
if( pNode )
{
THitTests ht = tv->GetHitTestInfoAt( X, Y );
if ( ht.Contains(htOnStateIcon) || ht.Contains(htOnIcon))
{
tv->Selected = pNode;
if ( pNode->StateIndex == 0 || pNode->StateIndex == 2 )
pNode->StateIndex = 1;
else
pNode->StateIndex = 2;
}
}
}
}
|