type
TForm1 = class(TForm)
ShellListView1: TShellListView;
Button1: TButton;
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyShellComboBox = class(TCustomShellComboBox) //派生一个子类,用于公开change方法。
published
procedure change;override;
end;
var
Form1: TForm1;
MyShellComboBox:TMyShellComboBox;
implementation
{$R *.dfm}
procedure TMyShellComboBox.Change;
begin
inherited;
end;
procedure TForm1.Button1Click(Sender: TObject);
//改变MyShellComboBox的path后调用change;
begin
with MyShellComBoBox do
begin
path:='c:\';
change;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyShellComboBox:=TmyShellComboBox.Create(self);
with MyShellComboBox do
begin
parent:=self;
left:=32;
top:=16;
height:=22;
width:=361;
shelllistview:=ShellListview1;
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
MyShellComboBox.Free;
end;