
30.05.2010, 21:09
|
Прохожий
|
|
Регистрация: 13.04.2010
Адрес: В России
Сообщения: 26
Репутация: 10
|
|
Код:
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm3 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
procedure Proc1; //Объявляем процедуру
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
proc1; //Используем в обработчике onClick
end;
procedure TForm3.Proc1;
var
r,i: Integer;
ArPanel: array of TControl;
Vis: boolean;
begin
for i := 0 to Form2.ControlCount -1 do
if Form2.Controls[i] is TPanel then
begin
SetLength(ArPanel, High(ArPanel) + 2); //Установка размера массива большего на 1
ArPanel[High(ArPanel)] := Form2.Controls[i];
end;
Randomize;
//Фрагмент нужен для того, чтобы не показывать панел второй раз
Repeat
r := Random(High(ArPanel) - Low(ArPanel) +1);
Vis := ArPanel[r].Visible;
ArPanel[r].Show;
Until not Vis ;
end;
end;
end.
|