OK. I've got the problem on my side now as well.
If you allready have form2 shown and then click the button to check radiobutton2 then if switched to radiobutton2, but when you activate form2 it goes back to radiobutton1?
And the reason for it is the following: your TabOrder for RadioButton1 is 0, so it is the first focus element on Form2.
If you set the button on it to be Taborder 0 then the code works as expected., or you can turn off tabstop for the 2 radiobuttons if no-one will use it with keyboard.
But it will still give strange results if someone selects the first radiobutton, then pushes the select radiobutton2 button on from1 and then switches back to the other form, because then the radiobutton will have focus, and by beeing activated will select radiobutton1 again.
The following makes sure that the focus on the form will not be a problem:
Form2.RadioButton2.Checked:=true;
Form2.SetFocusedControl(Form2.RadioButton2);
Form2.Show;
Gerald P?ttler
And3mD wrote 69 lines
I try move Show to the first line no changes, not working.
I made some test with:
- Lazarus 0.9.27 rev 17395, fpc 2.2.3 (snapshot)
- Lazarus 0.9.27 rev 17395, fpc 2.2.2 (snapshot)
- Lazarus 0.9.27 rev 17397, fpc 2.2.3 (compiled myself)
and it not working for me:
Can you download my test project and try:
http://and3md.xon.pl/lazarus/radiobuttontestsrc.zip
Exe file of this project:
http://and3md.xon.pl/lazarus/radiobuttontestexe.zip
REGARDS
Andrzej "And3mD" Kilijanski
> Are you sure you don't have RadioButton1 and RadioButton1 mixed up?
>
> I just tried this and it works fine for me (17397)
>
> Try moving the show to the first line
>
>
> Gerald P?ttler
>
>
>
>
> On Sat, Nov 15, 2008 at 3:33 PM, And3mD wrote:
>> Hello
>> How to change TRadioButton state when form is hidden (win32)?
>>
>> In Form2 I have 2 Radiobuttons. In Form1 I try do something like that:
>>
>> procedure TForm1.Button1Click(Sender: TObject);
>> begin
>> Form2.RadioButton2.Checked:=true;
>> if Form2.RadioButton2.Checked then
>> ShowMessage('RadioButton2.Checked:=true');
>> Form2.Show;
>> end;
>>
>> MessageBox with information "RadioButton2.Checked:=true" is showed, but
>> in
>> showed Form2 RadioButton1 is still checked.
>>
>> I use Lazarus 0.9.27 rev 17395, fpc 2.2.3 ,win32 - Windows Vista 32 bit
>>
>> REGARDS
>>
>> Andrzej "And3mD" Kilijanski
>> _______________________________________________
>> Lazarus mailing list
>>
>>
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>>
>
> _______________________________________________
> Lazarus mailing list
>
>
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
_______________________________________________
Lazarus mailing list
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus