ZIK1337
@ZIK1337

Выбор в двух radiogroup?

Почему-то не могу выбрать одновременно в двух группах (RadioGroup) что-то, выбирается только одно, а если выбирать во второй группе, то из первой группы выбор пропадает:
spoiler
n5aVjkF.jpg
spoiler
mRK7LI0.jpg
spoiler
klQjBXM.jpg

Код Unit_4:
spoiler
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.
  • Вопрос задан
  • 197 просмотров
Решения вопроса 1
tsklab
@tsklab
Здесь отвечаю на вопросы.
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;

У TRadioGroup нет отдельных TRadioGroup. Выбранное: RadioGroup1.ItemIndex.

Для разделения TRadioButton поместите их на разные TPanel или, да, TGroupBox.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы