mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 10:18:05 +02:00
Refactoring TTaskDialog:
- Change signature of TWSTaskDialog.Execute and related functions/methods so we can set ParentWnd and retrieve RadioRes. The TLCLTaskDialog now should act the same as the old emulated version (unit LCLTaskDialog).
This commit is contained in:
parent
1420ce0a69
commit
9a3e5c120d
@ -221,7 +221,7 @@ var
|
||||
TaskDlg: LCLTaskDialog.TTaskDialog;
|
||||
DefRB, DefBtn: TModalResult;
|
||||
B: TTaskDialogBaseButtonItem;
|
||||
ButtonID: Integer;
|
||||
ButtonID, ARadioRes: Integer;
|
||||
const
|
||||
TD_BTNMOD: array[TTaskDialogCommonButton] of Integer = (
|
||||
mrOk, mrYes, mrNo, mrCancel, mrRetry, mrAbort);
|
||||
@ -233,15 +233,14 @@ begin
|
||||
|
||||
//temporary show new, then old dialog, both in emulated mode (regardless of Flags)
|
||||
LCLTaskDialog.TaskDialogIndirect := nil;
|
||||
ButtonID := TWSTaskDialogClass(WidgetSetClass).Execute(Self);
|
||||
ButtonID := TWSTaskDialogClass(WidgetSetClass).Execute(Self, ParentWnd, ARadioRes);
|
||||
FModalResult := ButtonIDToModalResult(ButtonID);
|
||||
Result := (ButtonID >= 0);
|
||||
debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',ButtonID,', Result=',Result]);
|
||||
debugln(['New: ButtonID=',ButtonID]);
|
||||
debugln(['New: FModalResult=',FModalResult]);
|
||||
debugln(['New: VerifyChecked=',tfVerificationFlagChecked in FFlags]);
|
||||
//ToDo: we need to retrieve RadioResult, since we cannot set RadioButton (it's read only)
|
||||
|
||||
debugln(['New: ARadioRes=',ARadioRes]);
|
||||
FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0);
|
||||
|
||||
if RadioButtons.DefaultButton<> nil then
|
||||
@ -276,7 +275,7 @@ begin
|
||||
debugln(['Old: FModalResult=',FModalResult]);
|
||||
|
||||
//ToDo move FirstButtonIndex and FirstRadioButtonIndex to interface section Dialogs unit.
|
||||
|
||||
debugln(['Old: TaskDlg.RadioRes=',TaskDlg.RadioRes]);
|
||||
if (TaskDlg.RadioRes>=200) and (TaskDlg.RadioRes-200<RadioButtons.Count) then
|
||||
FRadioButton := RadioButtons[TaskDlg.RadioRes-200] as TTaskDialogRadioButtonItem
|
||||
else
|
||||
|
@ -161,7 +161,7 @@ type
|
||||
|
||||
TWin32WSTaskDialog = class(TWSTaskDialog)
|
||||
public
|
||||
class function Execute(const ADlg: TCustomTaskDialog): Integer; override;
|
||||
class function Execute(const ADlg: TCustomTaskDialog; AParentWnd: HWND; out ARadioRes: Integer): Integer; override;
|
||||
end;
|
||||
|
||||
function OpenFileDialogCallBack(Wnd: HWND; uMsg: UINT; {%H-}wParam: WPARAM;
|
||||
@ -1578,10 +1578,10 @@ var
|
||||
TaskDialogIndirect: function(AConfig: pointer; Res: PInteger;
|
||||
ResRadio: PInteger; VerifyFlag: PBOOL): HRESULT; stdcall;
|
||||
|
||||
class function TWin32WSTaskDialog.Execute(const ADlg: TCustomTaskDialog): Integer;
|
||||
class function TWin32WSTaskDialog.Execute(const ADlg: TCustomTaskDialog; AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
begin
|
||||
//writeln('TWin32WSTaskDialog.Execute');
|
||||
Result := inherited Execute(ADlg);
|
||||
Result := inherited Execute(ADlg, AParentWnd, ARadioRes);
|
||||
end;
|
||||
|
||||
procedure InitTaskDialogIndirect;
|
||||
|
@ -24,7 +24,6 @@ type
|
||||
private
|
||||
/// the Task Dialog structure which created the form
|
||||
FDlg: TTaskDialog;
|
||||
FRadioRes: Integer;
|
||||
FVerifyChecked: Boolean;
|
||||
RadioButtonArray: array of TRadioButton;
|
||||
|
||||
@ -58,9 +57,8 @@ type
|
||||
|
||||
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
|
||||
|
||||
function Execute: Integer;
|
||||
function Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
public
|
||||
property RadioRes: Integer read FRadioRes;
|
||||
end;
|
||||
|
||||
|
||||
@ -70,7 +68,7 @@ var
|
||||
TaskDialog_Translate: TTaskDialogTranslate;
|
||||
|
||||
|
||||
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog): Integer;
|
||||
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog; AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
|
||||
implementation
|
||||
|
||||
@ -228,7 +226,7 @@ end;
|
||||
|
||||
|
||||
{ -------------- }
|
||||
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog): Integer;
|
||||
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog; AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
var
|
||||
DlgForm: TLCLTaskDialog;
|
||||
begin
|
||||
@ -236,7 +234,7 @@ begin
|
||||
Result := -1;
|
||||
DlgForm := TLCLTaskDialog.CreateNew(ADlg);
|
||||
try
|
||||
Result := DlgForm.Execute;
|
||||
Result := DlgForm.Execute(AParentWnd, ARadioRes);
|
||||
finally
|
||||
FreeAndNil(DlgForm);
|
||||
end;
|
||||
@ -252,21 +250,19 @@ begin
|
||||
KeyPreview := True;
|
||||
end;
|
||||
|
||||
function TLCLTaskDialog.Execute: Integer;
|
||||
function TLCLTaskDialog.Execute(AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
var
|
||||
mRes, I: Integer;
|
||||
aParent: HWND;
|
||||
begin
|
||||
debugln(['TLCLTaskDialog.Execute: Assigned(FDlg)=',Assigned(FDlg)]);
|
||||
if not Assigned(FDlg) then
|
||||
Exit(-1);
|
||||
SetupControls;
|
||||
|
||||
aParent := FDlg.ParentWindow;
|
||||
//set form parent
|
||||
if (aParent <> 0) then
|
||||
if (AParentWnd <> 0) then
|
||||
for I := 0 to Screen.CustomFormCount-1 do
|
||||
if Screen.CustomForms[I].Handle = aParent then
|
||||
if Screen.CustomForms[I].Handle = AParentWnd then
|
||||
begin
|
||||
PopupParent := Screen.CustomForms[I];
|
||||
Break;
|
||||
@ -301,10 +297,10 @@ begin
|
||||
FDlg.Flags := FDlg.Flags - [tfVerificationFlagChecked]
|
||||
end;
|
||||
|
||||
FRadioRes := 0;
|
||||
ARadioRes := 0;
|
||||
for i := 0 to high(RadioButtonArray) do
|
||||
if RadioButtonArray[i].Checked then
|
||||
FRadioRes := i+FirstRadioButtonIndex;
|
||||
ARadioRes := i+FirstRadioButtonIndex;
|
||||
|
||||
|
||||
end;
|
||||
|
@ -106,7 +106,7 @@ type
|
||||
TWSTaskDialogClass = class of TWSTaskDialog;
|
||||
TWSTaskDialog = class(TWSLCLComponent)
|
||||
published
|
||||
class function Execute(const ADlg: TCustomTaskDialog): Integer; virtual;
|
||||
class function Execute(const ADlg: TCustomTaskDialog; AParentWnd: HWND; out ARadioRes: Integer): Integer; virtual;
|
||||
end;
|
||||
|
||||
{ WidgetSetRegistration }
|
||||
@ -198,10 +198,10 @@ end;
|
||||
|
||||
{ TWSTaskDialog }
|
||||
|
||||
class function TWSTaskDialog.Execute(const ADlg: TCustomTaskDialog): Integer;
|
||||
class function TWSTaskDialog.Execute(const ADlg: TCustomTaskDialog; AParentWnd: HWND; out ARadioRes: Integer): Integer;
|
||||
begin
|
||||
//writeln('TWSTaskDialog.Execute: Assigned(ADlg)=',Assigned(ADlg));
|
||||
Result := ExecuteLCLTaskDialog(TTaskDialog(ADlg));
|
||||
Result := ExecuteLCLTaskDialog(TTaskDialog(ADlg), AParentWnd, ARadiores);
|
||||
end;
|
||||
|
||||
{ WidgetSetRegistration }
|
||||
|
Loading…
Reference in New Issue
Block a user