
31.03.2011, 10:45
|
 |
Прохожий
|
|
Регистрация: 05.03.2011
Сообщения: 18
Репутация: 10
|
|
Работа со свойствами массива компонентов, созданных Run Time
Здравствуйте. В программе создается run time массив StaticText'oв:
Код:
private
{ Private declarations }
procedure onMouseUpStaticx(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
//...........................................................................
var
Form1: TForm1;
CurDispatch: IDispatch; {save the interface globally }
MyButtons:array of array of TStaticText;
timeLim: integer; // time limit of test
qCount:integer; // amount of questions
testName:string; // test's file name
testFile:file; // test file
ansArr:array of integer;
//.....................................................
//.....................................................
procedure TForm1.btnSetQuestionsClick(Sender: TObject);
var i, j,x: byte;
n,k: integer;
count:String;
begin
count:=inputbox('Test','Enter amount of questions','1');
try
n := StrToInt(count);
qCount:=n;
except
on EConvertError do ShowMessage('Someting is wrong');
end;
setlength(Mybuttons,n,4);
setlength(ansArr,n);
k:=0;
for i:=0 to n-1 do
for j:=0 to 3 do begin
inc(k);
MyButtons[i,j]:=TStaticText.Create(Panel1);
MyButtons[i,j].Parent := self;
MyButtons[i,j].Top:= ((i+1)*25)+33;//((i+1)-1)*Arr3[i,j].Height+50;
MyButtons[i,j].Left:=((j+1)*20)+830;//((j+1)-1)*Arr3[i,j].Width+800;
MyButtons[i,j].BorderStyle :=sbsSunken;
MyButtons[i,j].AutoSize :=false;
MyButtons[i,j].Alignment := taCenter;
MyButtons[i,j].Width:=20;
MyButtons[i,j].Height:=20;
MyButtons[i,j].Color :=clLime;
MyButtons[i,j].Tag:=k;
MyButtons[i,j].Caption :=IntToStr (k);
MyButtons[i,j].Font.Size:=10;
MyButtons[i,j].Name := 'Btn'+intToStr(k);
TStaticText(MyButtons[i,j]).onMouseUp:=onMouseUpStaticx; {new components event}
end;
for i:=0 to n-1 do
for j:=0 to 0 do begin
MyButtons[i,j].Caption :='a';
end;
for i:=0 to n-1 do
for j:=1 to 1 do begin
MyButtons[i,j].Caption :='b';
end;
for i:=0 to n-1 do
for j:=2 to 2 do begin
MyButtons[i,j].Caption :='c';
end;
for i:=0 to n-1 do
for j:=3 to 3 do begin
MyButtons[i,j].Caption :='d';
end;
end;
//.....................................................
procedure TForm1.onMouseUpStaticx(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
// вот здесь все это должно происходить
end;
//......................................................................
А теперь вопрос: как мне управлять свойством Enabled StaticText'oв, чтобы при выборе одной из ячеек недоступными становились все ячейки в этом ряду( строке)?
Заранее благодарен
|