Форум: "Основная";
Текущий архив: 2005.06.29;
Скачать: [xml.tar.bz2];
ВнизДинамическое создание формы Найти похожие ветки
← →
Serg1981 (2005-06-02 14:08) [0]Создаю форму:
...
var form : tForm;
begin
Application.CreateForm(TForm, Form);
Form.Caption := "Proba";
...
With TButton.Create(Form) do
begin
parent := Form;
Left := 12;
Top := 10;
end;
Form.Show
end;
...
Вопрос: как создать у такой формы события (onClose например) и как создать у кнопки события (onClick например) ?
← →
Ega23 © (2005-06-02 14:12) [1]
function ShowTexLogFile(const aFileName:String):Boolean;
procedure BtnClearClick(Sender:TObject);
var
i:Integer;
_memo:TMemo;
begin
if (Sender is TForm) then
begin
With TForm(Sender) do
begin
for i:=0 to ComponentCount-1 do
if (Components[i] is TMemo) then
if UpperCase(TMemo(Components[i]).Name)=UpperCase("memSQLLogMonitor") then
begin
_memo:=TMemo(Components[i]);
_memo.Lines.Clear;
_memo.Lines.Add(" ");
_memo.Lines.SaveToFile(_memo.Hint);
Break;
end;
end;//With TForm(Sender) do
end;//if (Sender is TForm) then
end;//procedure BtnClearClick(
var
aForm:TForm;
aPanel:TPanel;
OnClearClick:TMethod;
List:TStringList;
i:Integer;
begin
Result:=False;
//if not FileExists(aFileName) then Exit;
try
Application.CreateForm(TForm, aForm);
try
With aForm do
begin
Caption:=aFileName;
BorderStyle:=bsSingle;
Height:=500;
Width:=750;
Position:=poScreenCenter;
end;
With TMemo.Create(aForm) do
begin
Parent:=aForm;
Name:="memSQLLogMonitor";
Align:=alClient;
ScrollBars:=ssBoth;
//Height:=440;
Clear;
Hint:=aFileName;
List:=TStringList.Create;
if FileExists(aFileName) then
begin
List.LoadFromFile(aFileName);
for i:=List.Count-1 downto 0 do Lines.Add(List.Strings[i]);
end;
List.Free;
end;
aPanel:=TPanel.Create(aForm);
With aPanel do
begin
Parent:=aForm;
Height:=45;
Align:=alBottom;
end;
With TButton.Create(aPanel) do
begin
Parent:=aPanel;
Cancel:=True;
Height:=25;
Width:=100;
Font.Size:=10;
Top:=10; //aPanel.ClientHeight-10;
Left:=aPanel.Width-110;
Anchors:=[akTop, akRight];
Caption:="Çàêðûòü";
ModalResult:=mrOK;
end;
With TButton.Create(aPanel) do
begin
Parent:=aPanel;
Height:=25;
Width:=100;
Font.Size:=10;
Top:=10; //aPanel.ClientHeight-30;
Left:=aPanel.Width-220;
Anchors:=[akTop, akRight];
Caption:="Î÷èñòèòü";
OnClearClick.Code:=@BtnClearClick;
OnClearClick.Data:=aForm;
OnClick:=TNotifyEvent(OnClearClick);
end;
aForm.ShowModal;
finally
aForm.Free;
end;
except on E:Exception do
raise Exception.Create("ShowTexLogFile "+E.Message);
end;
end;
//***********************************************************************************
← →
stone © (2005-06-02 14:15) [2]примерно так
procedure ButtonClick(Sender: TObject);
...
With TButton.Create(Form) do
begin
parent := Form;
Left := 12;
Top := 10;
...
OnClick := ButtonClick;
end;
Страницы: 1 вся ветка
Форум: "Основная";
Текущий архив: 2005.06.29;
Скачать: [xml.tar.bz2];
Память: 0.46 MB
Время: 0.055 c