![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
||||
|
||||
|
Здравствуйте. В программе создается 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в, чтобы при выборе одной из ячеек недоступными становились все ячейки в этом ряду( строке)? Заранее благодарен |
|
#2
|
|||
|
|||
|
Ищи StaticEdit либо по имени, либо по тегу или по чему там еще объект найти можно, затем условием проверяй значение и делай что хочешь...
Я для работы с динамическими объектами всегда пользуюсь поиском... |
|
#3
|
||||
|
||||
|
Цитата:
a b c d a b c d ......... a b c d Кликнув на одной из ячеек надо блокировать все остальные ячейки в этом ряду: |
|
#4
|
|||
|
|||
|
Цитата:
Код:
procedure TForm1.onMouseUpStaticx(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i:integer;
begin
for i:=0 to Panel1.ComponentCount-1 do
begin
if Panel1.Components[i].ClassType = TStaticText then
if (TStaticText(Panel1.Components[i]).Top=TStaticText(Sender).Top) and
(Panel1.Components[i].Name<>TStaticText(Sender).Name) then
TStaticText(Panel1.Components[i]).Enabled:=False;
end;
end;Код:
//Вместо: MyButtons[i,j].Parent := Self; Надо: MyButtons[i,j].Parent := Panel1; |
| Этот пользователь сказал Спасибо Janom за это полезное сообщение: | ||
Rick (03.08.2012)
| ||
|
#5
|
||||
|
||||
|
Спасибо, щас протестируем.
|