Показать сообщение отдельно
  #12  
Старый 21.10.2008, 14:08
Rat Rat вне форума
Активный
 
Регистрация: 12.09.2008
Сообщения: 391
Репутация: 6078
По умолчанию

Может кому пригодиться... В общем я бы обращался вот так:
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    PageControl1: TPageControl;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  TSh: TTabSheet;
  Memo1, Memo2 : TMemo;
begin
      TSh := TTabSheet.Create(Self);
      TSh.Caption := 'PageCaption';
      TSh.Parent := Self;
      TSh.PageControl := PageControl1;
      PageControl1.ActivePage := TSh;
      Memo1 := TMemo.Create(TSh);
      Memo2 := TMemo.Create(Tsh);

      Memo1.Parent := TSh;
      Memo1.Align:= alTop;
      Memo1.Height := TSh.Height div 2;

      Memo2.Parent := TSh;
      Memo2.Align:= alBottom;
      Memo2.Height := TSh.Height div 2;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  i : Integer;
begin
  for i:=0 to PageControl1.ActivePage.ComponentCount-1 do
  begin
    if PageControl1.ActivePage.Components[i] is TMemo then
    begin
      if (PageControl1.ActivePage.Components[i] as TMemo).ComponentIndex = 0 then
      begin
        (PageControl1.ActivePage.Components[i] as TMemo).Lines.Add('one');
      end;
    end;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  i : Integer;
begin
  for i:=0 to PageControl1.ActivePage.ComponentCount-1 do
  begin
    if PageControl1.ActivePage.Components[i] is TMemo then
    begin
      if (PageControl1.ActivePage.Components[i] as TMemo).ComponentIndex = 1 then
      begin
        (PageControl1.ActivePage.Components[i] as TMemo).Lines.Add('two');
      end;
    end;
  end;
end;

end.

На форме должно быть три кнопки и один TPageControl.

Цитата:
вопрос правильности/неправильности такого создания мы в данном контексте опустим.
Aristarh Dark а как все таки правильно создавать?
Ответить с цитированием