W
wjs
Unregistered / Unconfirmed
GUEST, unregistred user!
unit selectdirectory;
interface
function selectdir(const showcaption, viewtext: string;
var value: string): boolean;
implementation
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ShellCtrls;
function selectdir(const showcaption, viewtext: string;
var value: string): boolean;
var
form: Tform;
ShellTreeView: TShellTreeView;
viewt: Tlabel;
btnOK, btnCancel: Tbutton;
begin
form := Tform.Create(nil);
with form do
begin
Width := 386;
Height := 435;
Caption := showcaption ;
borderstyle := bsSizeable; // 可改变大小
position := poScreenCenter;
icon.Handle := Application.Handle;
end;
ShellTreeView := TShellTreeView.Create(nil); // 目录控件
with ShellTreeView do
begin
Parent := Form;
Left := 16;
Top := 48;
Width := 345 ;
Height := 305;
end;
btnOK := Tbutton.Create(nil);
with btnOK do
begin
parent := form;
modalresult:=mrok;
Left := 144 ;
Top := 368 ;
Width := 75 ;
Height := 25 ;
Caption := 'OK';
Default := True ;
TabOrder := 1 ;
end;
btnCancel := Tbutton.Create(nil);
with btnCancel do
begin
parent := form;
Left := 246;
Top := 368;
Width := 75 ;
Height := 25;
Caption := 'Cancel';
modalresult := mrcancel;
Cancel := True;
ModalResult := 2 ;
TabOrder := 2 ;
end;
viewt := Tlabel.Create(nil);
with viewt do
begin
parent := form;
left := 16;
Top := 16 ;
Width := 133;
Height := 14;
Caption := viewtext;
Font.Size :=11;
Font.Name := '宋体';
end;
if form.ShowModal = mrOk then
begin
value := ShellTreeView.Path ;
result := true;
end;
form.free ;
end;
end.
我想为窗体添加 OnSize事件按处理,怎样添加?
interface
function selectdir(const showcaption, viewtext: string;
var value: string): boolean;
implementation
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ShellCtrls;
function selectdir(const showcaption, viewtext: string;
var value: string): boolean;
var
form: Tform;
ShellTreeView: TShellTreeView;
viewt: Tlabel;
btnOK, btnCancel: Tbutton;
begin
form := Tform.Create(nil);
with form do
begin
Width := 386;
Height := 435;
Caption := showcaption ;
borderstyle := bsSizeable; // 可改变大小
position := poScreenCenter;
icon.Handle := Application.Handle;
end;
ShellTreeView := TShellTreeView.Create(nil); // 目录控件
with ShellTreeView do
begin
Parent := Form;
Left := 16;
Top := 48;
Width := 345 ;
Height := 305;
end;
btnOK := Tbutton.Create(nil);
with btnOK do
begin
parent := form;
modalresult:=mrok;
Left := 144 ;
Top := 368 ;
Width := 75 ;
Height := 25 ;
Caption := 'OK';
Default := True ;
TabOrder := 1 ;
end;
btnCancel := Tbutton.Create(nil);
with btnCancel do
begin
parent := form;
Left := 246;
Top := 368;
Width := 75 ;
Height := 25;
Caption := 'Cancel';
modalresult := mrcancel;
Cancel := True;
ModalResult := 2 ;
TabOrder := 2 ;
end;
viewt := Tlabel.Create(nil);
with viewt do
begin
parent := form;
left := 16;
Top := 16 ;
Width := 133;
Height := 14;
Caption := viewtext;
Font.Size :=11;
Font.Name := '宋体';
end;
if form.ShowModal = mrOk then
begin
value := ShellTreeView.Path ;
result := true;
end;
form.free ;
end;
end.
我想为窗体添加 OnSize事件按处理,怎样添加?