Refactoring TTaskDialog:

- Fix not displaying common buttons in TLCLTaskDialog.SetupControls
- Assign TLCLDialog.FDlg in the CreateNew() constructor.
- Free LDefaultFont
- Start comparing the new form vs the old form
Still not functional.
This commit is contained in:
Bart 2023-07-19 19:43:35 +02:00
parent 916196dede
commit b163a35cb3
3 changed files with 20 additions and 4 deletions

View File

@ -230,6 +230,13 @@ begin
//Result := TWSTaskDialogClass(WidgetSetClass).Execute(Self);
FParentWindow := ParentWnd;
//temporary show new, then old dialog, both in emulated mode (regardless of Flags)
LCLTaskDialog.TaskDialogIndirect := nil;
Result := TWSTaskDialogClass(WidgetSetClass).Execute(Self);
debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',Result]);
FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0);
if RadioButtons.DefaultButton<> nil then
@ -258,10 +265,10 @@ begin
DefRB, FWidth, ParentWnd, tfForceNonNative in Flags, tfEmulateClassicStyle in Flags, @DoOnButtonClickedHandler);
Result := ButtonID>=0;
FModalResult := ButtonIDToModalResult(ButtonID);
//ToDo move FirstButtonIndex and FirstRadioButtonIndex to interface section Dialogs unit.
if (TaskDlg.RadioRes>=200) and (TaskDlg.RadioRes-200<RadioButtons.Count) then
FRadioButton := RadioButtons[TaskDlg.RadioRes-200] as TTaskDialogRadioButtonItem
else

View File

@ -159,7 +159,10 @@ end;
constructor TLCLTaskDialog.CreateNew(AOwner: TComponent; Num: Integer);
begin
debugln('TLCLTaskDialog.CreateNew: AOwner=',DbgSName(AOwner));
inherited CreateNew(AOwner, Num);
if (AOwner is TCustomTaskDialog) then
FDlg := TTaskDialog(AOwner);
Rad := nil;
KeyPreview := True;
end;
@ -169,6 +172,7 @@ var
mRes, I: Integer;
aParent: HWND;
begin
debugln(['TLCLTaskDialog.Execute: Assigned(FDlg)=',Assigned(FDlg)]);
if not Assigned(FDlg) then
Exit(False);
SetupControls;
@ -684,7 +688,7 @@ begin
// add buttons and verification checkbox
if (aCommonButtons=[]) or (Verify<>'') or
if (aCommonButtons <> []) or (Verify<>'') or
((Buttons<>'') and not (tfUseCommandLinks in FDlg.Flags)) then
begin
CurrTabOrder := Panel.TabOrder;
@ -700,8 +704,10 @@ begin
Free;
end;
for Btn := high(TTaskDialogCommonButton) downto low(TTaskDialogCommonButton) do
begin
if (Btn in aCommonButtons) then
AddButton(TD_Trans(LoadResString(TD_BTNS(Btn))), TD_BTNMOD[Btn]);
end;
if Verify<>'' then
begin
Verif := TCheckBox.Create(Self);
@ -771,6 +777,9 @@ begin
inherited KeyDown(Key, Shift);
end;
finalization
if assigned(LDefaultFont) then
LDefaultFont.Free;
end.

View File

@ -200,7 +200,7 @@ end;
class function TWSTaskDialog.Execute(const ADlg: TCustomTaskDialog): Boolean;
begin
//writeln('TWSTaskDialog.Execute');
//writeln('TWSTaskDialog.Execute: Assigned(ADlg)=',Assigned(ADlg));
Result := ExecuteLCLTaskDialog(TTaskDialog(ADlg));
end;