![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Проблема с RadioButton [D6, XP]
webpauk © (2006-11-29 16:39:00)есть 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:48:00) [1]короче проект уровня "HellO, Word!'
только не фурычит
webpauk (2006-11-29 18:47:00) [2]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:43:00) [3]
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.
Джо (2006-11-29 18:42:00) [4]> [13] webpauk (29.11.06 18:40)
>
> > Джо © (29.11.06 18:38) [12]
>
> тогда что?
Возможно, погода на Марсе неблагоприятствует. Покажи хоть dpr.
webpauk (2006-11-29 18:42:00) [5]кстати, что имеется в виду под AutoCreate
webpauk (2006-11-29 18:41:00) [6]различий нет
webpauk (2006-11-29 18:40:00) [7]
> Джо © (29.11.06 18:38) [12]
тогда что?
Джо (2006-11-29 18:38:00) [8]> [11] webpauk (29.11.06 18:36)
> значт D6
И у меня D6.
webpauk (2006-11-29 18:36:00) [9]значт D6
Джо (2006-11-29 18:35:00) [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:31:00) [11]вот полный код обеих форм:
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:31:00) [12]> [7] webpauk (29.11.06 18:30)
>
> > Джо © (29.11.06 18:27) [6]
>
> попробуй у себя
Именно так и сделал перед написанием поста [3].
webpauk (2006-11-29 18:30:00) [13]
> Джо © (29.11.06 18:27) [6]
попробуй у себя
Джо (2006-11-29 18:27:00) [14]> [4] webpauk (29.11.06 18:25)
>
> > Джо © (29.11.06 18:24) [3]
>
> ну и где ты видишь ошибку?
Здесь я ее не вижу (разве что возможный "зародыш ошибки" в Button1Click). Она, вероятно, в другом месте, о чем я тебе и сказал.
webpauk (2006-11-29 18:27:00) [15]если при закрытии формы2 был помечен radiobutton2, то radiobutton1 - Не помечается
webpauk (2006-11-29 18:25:00) [16]
> Джо © (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;
Джо (2006-11-29 18:24:00) [17]Ищи ошибку в программе.
webpauk (2006-11-29 18:22:00) [18]а ежели на Form2 бросить radiogroup с 2 item, то
procedure TForm2.FormShow(Sender: TObject);
begin
RadioGroup1.ItemIndex:=0;
end;
тоже не фурычит
webpauk (2006-11-29 18:21:00) [19]меня не слышат...