- [남군]빛고을총각
- 0
- 68
- 0
- 0
- 2019-08-05 16:04:37
- 관련링크
- 제목 : treeview with checkbox
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
IdFTP, CommCtrl;
type
TForm1 = class(TForm)
IdFTP1: TIdFTP;
Button1: TButton;
TreeView1: TTreeView;
ListView1: TListView;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
TVIS_CHECKED = $2000;
TIVS_UNcHECKED= $1000;
implementation
{$R *.dfm}
function isChecked(Node : TTreeNode):boolean;
var
TVItem: TTVItem;
begin
TvItem.Mask := TVIF_STATE;
tvitem.hItem:= node.ItemId;
TreeView_GetItem(node.TreeView.Handle, TVItem);
Result:= (TVItem.state and TVIS_CHECKED > 0);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
node: TTreeNode;
begin
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowLong(Treeview1.Handle, GWL_STYLE, GetWindowLong(TreeView1.handle, GWL_STYLE) OR TVS_CHECKBOXES);
end;
procedure TForm1.ToggleTreeViewCheckBoxes(Node: TTreeNode; cUnChecked, cChecked: integer);
begin
if Assigned(Node) then
begin
if Node.StateIndex = cUnChecked then
Node.StateIndex := cChecked
else if Node.StateIndex = cChecked then
Node.StateIndex := cUnChecked;
end;
end;
procedure TForm1.TreeView1Click(Sender: TObject);
begin
if isChecked(TreeView1.selected) then
begin
label1.caption:= ' checked ';
end
else
begin
label1.Caption:= 'unchecked';
end;
end;
end.
- 첨부파일
- 댓글