Hello,
I am writing a TTreeView descendent which handles CheckBoxes. I've done
this by using the TreeView_SetItem API call with appropriate flags and
so far it works well. However, I have come to the point where I want to
respond to a mouse click on a checkbox, and know which is the
corresponding node.
I have overridden the MouseDown method, done the appropriate HitTest
and I fire an event. So far so good. The problem is that when this
occurs, the TTreeView still thinks the currently selected node is the
last one, if you see what I mean.
How can I force the TreeView to change the Selected property to the
node which corresponds to the checkbox which has just been clicked?
--
Cheers,
Carl
I've sorted this now using...
procedure TcaTreeView.WMLButtonDown(var Message: TWMLButtonDown);
var
Node: TTreeNode;
begin
inherited;
if htOnStateIcon in GetHitTestInfoAt(Message.XPos, Message.YPos) then
begin
Node := GetNodeAt(Message.XPos, Message.YPos);
if Assigned(Node) then
begin
Node.Focused := True;
Node.Selected := True;
end;
DoCheckBoxClicked;
end;
end;
--
Carl