Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.12.17;
Скачать: CL | DM;

Вниз

Проблема с RadioButton   Найти похожие ветки 

 
webpauk   (2006-11-29 16:39) [0]

есть 2 формы Form1, Form2
на Form2 есть 2 radiobutton +
procedure TForm2.FormShow(Sender: TObject);
begin
 RadioButton1.Checked:=True;
end;


проблема вот в чем: при вызове из Form1 - Form2.Show если был помечен radiobutton2, то хоть и выполняется метод OnShow, но radiobutton1 не изменяет своего состояния


 
webpauk   (2006-11-29 18:21) [1]

меня не слышат...


 
webpauk   (2006-11-29 18:22) [2]

а ежели на Form2 бросить radiogroup с 2 item, то

procedure TForm2.FormShow(Sender: TObject);
begin
RadioGroup1.ItemIndex:=0;
end;

тоже не фурычит


 
Джо ©   (2006-11-29 18:24) [3]

Ищи ошибку в программе.


 
webpauk   (2006-11-29 18:25) [4]


> Джо ©   (29.11.06 18:24) [3]

ну и где ты видишь ошибку?
всего 2 процедуры:

procedure TForm1.Button1Click(Sender: TObject);
begin
 Form2.Show
end;


procedure TForm2.FormShow(Sender: TObject);
begin
 RadioButton1.Checked:=True;
end;


 
webpauk   (2006-11-29 18:27) [5]

если при закрытии формы2 был помечен radiobutton2, то radiobutton1 - Не помечается


 
Джо ©   (2006-11-29 18:27) [6]

> [4] webpauk   (29.11.06 18:25)
>
> > Джо ©   (29.11.06 18:24) [3]
>
> ну и где ты видишь ошибку?

Здесь я ее не вижу (разве что возможный "зародыш ошибки" в Button1Click). Она, вероятно, в другом месте, о чем я тебе и сказал.


 
webpauk   (2006-11-29 18:30) [7]


> Джо ©   (29.11.06 18:27) [6]

попробуй у себя


 
Джо ©   (2006-11-29 18:31) [8]

> [7] webpauk   (29.11.06 18:30)
>
> > Джо ©   (29.11.06 18:27) [6]
>
> попробуй у себя

Именно так и сделал перед написанием поста [3].


 
webpauk   (2006-11-29 18:31) [9]

вот полный код обеих форм:
unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 Form2.Show
end;

end.


unit Unit2;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm2 = class(TForm)
   RadioButton1: TRadioButton;
   RadioButton2: TRadioButton;
   procedure FormShow(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormShow(Sender: TObject);
begin
 RadioButton1.Checked:=True;
end;

end.


 
Джо ©   (2006-11-29 18:35) [10]

> [9] webpauk   (29.11.06 18:31)
> вот полный код обеих форм:

Вот полный код двух юнитов, в которых вышеописанное тобой поведение не наблюдается.

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 Form2.Show
end;

end.

unit Unit2;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm2 = class(TForm)
   RadioButton1: TRadioButton;
   RadioButton2: TRadioButton;
   procedure FormShow(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormShow(Sender: TObject);
begin
 RadioButton1.Checked:=True;
end;

end.


Найдите 10 отличий.

П.С. AutoCreate для Form2 включен.


 
webpauk   (2006-11-29 18:36) [11]

значт D6


 
Джо ©   (2006-11-29 18:38) [12]

> [11] webpauk   (29.11.06 18:36)
> значт D6

И у меня D6.


 
webpauk   (2006-11-29 18:40) [13]


> Джо ©   (29.11.06 18:38) [12]

тогда что?


 
webpauk   (2006-11-29 18:41) [14]

различий нет


 
webpauk   (2006-11-29 18:42) [15]

кстати, что имеется в виду под AutoCreate


 
Джо ©   (2006-11-29 18:42) [16]

> [13] webpauk   (29.11.06 18:40)
>
> > Джо ©   (29.11.06 18:38) [12]
>
> тогда что?

Возможно, погода на Марсе неблагоприятствует. Покажи хоть dpr.


 
webpauk   (2006-11-29 18:43) [17]

program Project1;

uses
 Forms,
 Unit1 in "Unit1.pas" {Form1},
 Unit2 in "Unit2.pas" {Form2};

{$R *.res}

begin
 Application.Initialize;
 Application.CreateForm(TForm1, Form1);
 Application.CreateForm(TForm2, Form2);
 Application.Run;
end.


 
webpauk   (2006-11-29 18:47) [18]

dfm:
object Form1: TForm1
 Left = 190
 Top = 110
 Width = 870
 Height = 640
 Caption = "Form1"
 Color = clBtnFace
 Font.Charset = DEFAULT_CHARSET
 Font.Color = clWindowText
 Font.Height = -11
 Font.Name = "MS Sans Serif"
 Font.Style = []
 OldCreateOrder = False
 PixelsPerInch = 96
 TextHeight = 13
 object Button1: TButton
   Left = 660
   Top = 165
   Width = 75
   Height = 25
   Caption = "Button1"
   TabOrder = 0
   OnClick = Button1Click
 end
end


object Form2: TForm2
 Left = 190
 Top = 110
 Width = 870
 Height = 640
 Caption = "Form2"
 Color = clBtnFace
 Font.Charset = DEFAULT_CHARSET
 Font.Color = clWindowText
 Font.Height = -11
 Font.Name = "MS Sans Serif"
 Font.Style = []
 OldCreateOrder = False
 OnShow = FormShow
 PixelsPerInch = 96
 TextHeight = 13
 object RadioButton1: TRadioButton
   Left = 273
   Top = 81
   Width = 113
   Height = 17
   Caption = "RadioButton1"
   TabOrder = 0
 end
 object RadioButton2: TRadioButton
   Left = 276
   Top = 126
   Width = 113
   Height = 17
   Caption = "RadioButton2"
   TabOrder = 1
 end
end


 
webpauk   (2006-11-29 18:48) [19]

короче проект уровня "HellO, Word!"
только не фурычит



Страницы: 1 вся ветка

Текущий архив: 2006.12.17;
Скачать: CL | DM;

Наверх




Память: 0.51 MB
Время: 0.058 c
15-1164670569
vasIzmax
2006-11-28 02:36
2006.12.17
Вопрос не по теме


2-1164646397
Алик
2006-11-27 19:53
2006.12.17
Мигание TPaintBox при перерисовке Canvas


9-1140196538
VolanD666
2006-02-17 20:15
2006.12.17
Косячит алгоритм?


4-1155441360
wiln
2006-08-13 07:56
2006.12.17
Использование мыши для перемещения окна


2-1164627544
mmms
2006-11-27 14:39
2006.12.17
Можно ли в TRichEdit вывести текст с фоном произв. цвета?