Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 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.038 c
1-1118126471
Леонид
2005-06-07 10:41
2005.06.29
Как запретить ввод значений в combobox


1-1117582199
TrueCoder
2005-06-01 03:29
2005.06.29
Ошибка "Out of memory"


3-1116054214
_Вован
2005-05-14 11:03
2005.06.29
Как с помощью Local SQL создать пароль для Paradox-таблицы ?


1-1118062914
Олег из Москвы
2005-06-06 17:01
2005.06.29
Непонятные ошибки.


1-1118157641
Vitalik
2005-06-07 19:20
2005.06.29
runtime пакеты





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский