procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
HitInfo: THitTests;
node: TTreeNode;
Pos: TPoint;
begin
GetCursorPos(Pos);
Pos := self.TreeView1.ScreenToClient(Pos);
with Pos do
begin
HitInfo := self.TreeView1.GetHitTestInfoAt(X, Y);
node := self.TreeView1.GetNodeAt(X, Y);
end;
if (node <> nil) and (HtOnStateIcon in HitInfo) then
begin
//这里就是发挥的地方了!
end;
end;
function TXTreeView.IsNodeCheck(Node: TTreeNode): Boolean;
var
TvItem: TTVItem;
begin
Result := False;
if Node = nil then Exit;
TvItem.hItem := Node.ItemId;
TvItem.mask := TVIF_STATE;
TreeView_GetItem(Node.TreeView.Handle, TvItem);
Result := (TvItem.state and TVS_CHECK) = TVS_CHECK;
end;
应该会做了吧!