
09.02.2008, 09:59
|
Прохожий
|
|
Регистрация: 26.01.2008
Сообщения: 49
Репутация: 10
|
|
Или включить функцию в тело класса формы...
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
function open1:string;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.open1:string;
begin
if OpenDialog1.Execute then
result := OpenDialog1.filename;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
name:string;
begin
name:=open1;
end;
end.
У тебя же объект находится на форме...
или... как вариант..
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
function open1:string;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function open1(OpenDl : TOpenDialog):string;
begin
if OpenDl.Execute then
result := OpenDl.filename;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
name:string;
begin
name:=open1(OpenDialog1);
end;
end.
|