Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TTreeView and CheckBoxes

44 views
Skip to first unread message

Carl Caulkett

unread,
Apr 23, 2008, 3:53:25 PM4/23/08
to
Delphi for Win32 2007 + WinXP Pro

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

Carl Caulkett

unread,
Apr 24, 2008, 7:00:35 AM4/24/08
to
Carl Caulkett wrote:

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

Sérgio Alexandre

unread,
Apr 25, 2008, 2:40:59 PM4/25/08
to
I have my own "checked treeview", and i use stateimages/stateindex and some
overrides to get a perfect result.
The internal checkboxes on treeview also uses the stateindex to determine if
is checked or not. I'm sorry to say that if you really need to go by "vcl"
way to acomplish a good result instead windows API.
If you want, I can send to your email the source code of my unit, i can't
post any source code on this newsgroup. (by the way, i use a 3rd party unit
from ehlib to enable xp theme on checkbox also, you can use the default
"DrawFrameControl" api to create the checkbox images on the
stateimagelist...)


0 new messages