Answer the question
In order to leave comments, you need to log in
Choice in two radiogroup?
For some reason, I can’t select something in two groups (RadioGroup) at the same time, only one is selected, and if you select in the second group, then the choice disappears from the first group:
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls, Unit4_1;
type
TForm1 = class(TForm)
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioGroup2: TRadioGroup;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
Button1: TButton;
Button2: TButton;
Button3: TButton;
TrackBar1: TTrackBar;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
PaintBox1: TPaintBox;
PaintBox2: TPaintBox;
PaintBox3: TPaintBox;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormKeyPress(Sender: TObject; var Key: Char);
procedure TrackBar1Change(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
Thread: array[1..3] of TMoveThread;
end;
var
Form1: TForm1;
level: integer;
presskey: boolean;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
RadioButton5.Checked:=true;
thread[1]:=TMoveThread.Create(PaintBox1);//Создается поток
Thread[1].Priority:=tpLowest; //Устанавливается небольшой приоритет у потока, чтобы поток был управляемым и не забирал все ресурсы.
thread[2]:=TMoveThread.Create(PaintBox2);//Создается поток
Thread[2].Priority:=tpLowest; //Устанавливается небольшой приоритет у потока, чтобы поток был управляемым и не забирал все ресурсы.
thread[3]:=TMoveThread.Create(PaintBox3);//Создается поток
Thread[3].Priority:=tpLowest; //Устанавливается небольшой приоритет у потока, чтобы поток был управляемым и не забирал все ресурсы.
RadioButton2.Checked:=true;
presskey:=false;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
x:integer;
begin
RadioButton1.Enabled:=False;
RadioButton2.Enabled:=False;
RadioButton3.Enabled:=False;
RadioButton4.Enabled:=False;
RadioButton5.Enabled:=False;
Button1.Enabled:=false;
TrackBar1.enabled:=false;
if RadioButton3.checked=true then level:=3;
if RadioButton2.checked=true then level:=2;
if RadioButton1.checked=true then level:=1;
for x:=1 to level do
begin
thread[x].DoVisualSwap;
Thread[x].resume;
presskey:=true;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
x:integer;
begin
RadioButton1.Enabled:=true;
RadioButton2.Enabled:=true;
RadioButton3.Enabled:=true;
RadioButton4.Enabled:=true;
RadioButton5.Enabled:=true;
Button1.Enabled:=true;
TrackBar1.enabled:=true;
presskey:=false;
for x:=1 to level do
begin
PaintBox1.Refresh;
PaintBox2.Refresh;
PaintBox3.Refresh;
Thread[x].er:=0;
edit1.Text:=inttostr(0);
thread[x].terminate;
thread[x].DoVisualSwap;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
var
x:integer;
begin
if presskey=true then
begin
for x:= 1 to level do
if thread[x].b0 = Key then
begin
thread[x].DoVisualSwap;
PaintBox1.Refresh;
PaintBox2.Refresh;
PaintBox3.Refresh;
exit;
end;
thread[1].er:=(thread[1].er)+1;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
x:integer;
begin
for x:=1 to level do
begin
if presskey=true then
begin
thread[x].Execute;
thread[x].go:=true;
edit1.Text:=inttostr((thread[1].er)+(thread[2].er)+(thread[3].er));
end;
end;
end;
procedure TForm1.TrackBar1Change(Sender: TObject);
begin
Timer1.Interval := 70 - TrackBar1.Position*20;
end;
end.
Answer the question
In order to leave comments, you need to log in
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
TRadioGroup
no separate TRadioGroup
. Selected: RadioGroup1.ItemIndex
. TRadioButton
put them on different TPanel
or, yes, TGroupBox
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question