控件开发 treeview图片 ( 积分: 0 )

  • 主题发起人 主题发起人 smilyvm
  • 开始时间 开始时间
S

smilyvm

Unregistered / Unconfirmed
GUEST, unregistred user!
private
{ Private declarations }
openbmp:TBitmap;
closebmp:TBitmap;
lastbmp:TBitmap;
selectbmp:TBitmap;
imglst:TImageList;
constructor THeTreeView.Create(Aowner: TComponent);
begin
inherited Create(AOwner);
imglst:=TCustomImageList.Create(self);
closebmp:=Tbitmap.Create;
openbmp:=Tbitmap.Create;
lastbmp:=Tbitmap.Create;
selectbmp:=Tbitmap.Create;
closebmp.LoadFromResourceName(HInstance,'close');
openbmp.LoadFromResourceName(HInstance,'open');
lastbmp.LoadFromResourceName(HInstance,'last');
selectbmp.LoadFromResourceName(HInstance,'select');
Images:=imglst;
imglst.Add(closebmp,nil);
imglst.Add(openbmp,nil);
imglst.Add(lastbmp,nil);
imglst.Add(selectbmp,nil);
procedure THeTreeView.GetImageIndex(Node: TTreeNode);
begin
inherited;
if Node.HasChildren then
begin
if Node.Expanded
then
Node.ImageIndex:=1
else
Node.ImageIndex:=0;
end
else
if Node.Selected then
Node.ImageIndex:=3
else
Node.ImageIndex:=2;
end;

procedure THeTreeView.GetSelectedIndex( Node: TTreeNode);
begin
inherited;
Node.SelectedIndex:=Node.ImageIndex;
end;

显示的时候用鼠标点击节点图片不变成selectbmp,怎么回事?
哪位大哥能指点指点。。
 
后退
顶部