TTaskDialog Do not work with radio buttons on Windows
Original Reporter info from Mantis: imants_gulbis
-
Reporter name: Imants Gulbis
Original Reporter info from Mantis: imants_gulbis
- Reporter name: Imants Gulbis
Description:
It is impossible to check which radio-button is selected because "RadioButton" property is never set.
Steps to reproduce:
begin
if not dlgIcon.Execute then
Exit;
case dlgIcon.RadioButton.Index of
0:;
1:;
2:;
end
end;
dlgIcon.RadioButton.Index will always cause access violation because it is never set.
Additional information:
I checked Lazarus code and saw funny thing.
function TCustomTaskDialog.DoExecute(ParentWnd: HWND): Boolean;
...
begin
...
ButtonID := TaskDlg.Execute(TD_COMMONBUTTONS(CommonButtons), DefBtn, TD_FLAGS(Flags), TF_DIALOGICON(MainIcon), TF_FOOTERICON(FooterIcon),
DefRB, 0, ParentWnd, False, False, @DoOnButtonClickedHandler);
Result := ButtonID>=0;
FModalResult := ButtonIDToModalResult(ButtonID);
if (TaskDlg.RadioRes>=0) and (TaskDlg.RadioRes<RadioButtons.Count) then
FRadioButton := RadioButtons[TaskDlg.RadioRes] as TTaskDialogRadioButtonItem
else
FRadioButton := nil;
end;
And in Lcl TTaskDialog I saw this code
function TTaskDialog.Execute(...): integer;
...
begin
...
RadioRes := 0;
for i := 0 to high(Rad) do
if Rad[i].Checked then
RadioRes := i+200;
...
end;
If radiobutton is selected then RadioRes is always 200 or larger. So this "TaskDlg.RadioRes&LtPos;RadioButtons.Count" will never be true and FRadioButton will always be nil
Mantis conversion info:
- Mantis ID: 32231
- OS: Windows
- OS Build: Windows 7
- Platform: Win64
- Version: 1.8RC3
- Fixed in revision: 55653 (#54ba2751)
- Monitored by: » howardpc (Howard Page-Clark)