mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 07:39:24 +02:00
Refactoring TTaskDialog:
- TWSTaskDialog.Execute: return integer (modal result of the dialog) instead of boolean - Idem for related functions and methods
This commit is contained in:
parent
e1dd886c07
commit
c3c73c48fc
@ -233,8 +233,12 @@ begin
|
|||||||
|
|
||||||
//temporary show new, then old dialog, both in emulated mode (regardless of Flags)
|
//temporary show new, then old dialog, both in emulated mode (regardless of Flags)
|
||||||
LCLTaskDialog.TaskDialogIndirect := nil;
|
LCLTaskDialog.TaskDialogIndirect := nil;
|
||||||
Result := TWSTaskDialogClass(WidgetSetClass).Execute(Self);
|
ButtonID := TWSTaskDialogClass(WidgetSetClass).Execute(Self);
|
||||||
debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',Result]);
|
FModalResult := ButtonIDToModalResult(ButtonID);
|
||||||
|
Result := (ButtonID >= 0);
|
||||||
|
debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',ButtonID,', Result=',Result]);
|
||||||
|
debugln(['New: ButtonID=',ButtonID]);
|
||||||
|
debugln(['New: FModalResult=',FModalResult]);
|
||||||
|
|
||||||
|
|
||||||
FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0);
|
FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0);
|
||||||
@ -263,9 +267,12 @@ begin
|
|||||||
|
|
||||||
ButtonID := TaskDlg.Execute(TD_COMMONBUTTONS(CommonButtons), DefBtn, TD_FLAGS(Flags), TF_DIALOGICON(MainIcon), TF_FOOTERICON(FooterIcon),
|
ButtonID := TaskDlg.Execute(TD_COMMONBUTTONS(CommonButtons), DefBtn, TD_FLAGS(Flags), TF_DIALOGICON(MainIcon), TF_FOOTERICON(FooterIcon),
|
||||||
DefRB, FWidth, ParentWnd, tfForceNonNative in Flags, tfEmulateClassicStyle in Flags, @DoOnButtonClickedHandler);
|
DefRB, FWidth, ParentWnd, tfForceNonNative in Flags, tfEmulateClassicStyle in Flags, @DoOnButtonClickedHandler);
|
||||||
|
debugln(['TaskDlg.Execute()=',ButtonID,', Result=',Result]);
|
||||||
|
debugln(['Old: ButtonID=',ButtonID]);
|
||||||
Result := ButtonID>=0;
|
Result := ButtonID>=0;
|
||||||
|
|
||||||
FModalResult := ButtonIDToModalResult(ButtonID);
|
FModalResult := ButtonIDToModalResult(ButtonID);
|
||||||
|
debugln(['Old: FModalResult=',FModalResult]);
|
||||||
|
|
||||||
//ToDo move FirstButtonIndex and FirstRadioButtonIndex to interface section Dialogs unit.
|
//ToDo move FirstButtonIndex and FirstRadioButtonIndex to interface section Dialogs unit.
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ type
|
|||||||
|
|
||||||
TWin32WSTaskDialog = class(TWSTaskDialog)
|
TWin32WSTaskDialog = class(TWSTaskDialog)
|
||||||
public
|
public
|
||||||
class function Execute(const ADlg: TCustomTaskDialog): Boolean; override;
|
class function Execute(const ADlg: TCustomTaskDialog): Integer; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function OpenFileDialogCallBack(Wnd: HWND; uMsg: UINT; {%H-}wParam: WPARAM;
|
function OpenFileDialogCallBack(Wnd: HWND; uMsg: UINT; {%H-}wParam: WPARAM;
|
||||||
@ -1578,7 +1578,7 @@ var
|
|||||||
TaskDialogIndirect: function(AConfig: pointer; Res: PInteger;
|
TaskDialogIndirect: function(AConfig: pointer; Res: PInteger;
|
||||||
ResRadio: PInteger; VerifyFlag: PBOOL): HRESULT; stdcall;
|
ResRadio: PInteger; VerifyFlag: PBOOL): HRESULT; stdcall;
|
||||||
|
|
||||||
class function TWin32WSTaskDialog.Execute(const ADlg: TCustomTaskDialog): Boolean;
|
class function TWin32WSTaskDialog.Execute(const ADlg: TCustomTaskDialog): Integer;
|
||||||
begin
|
begin
|
||||||
//writeln('TWin32WSTaskDialog.Execute');
|
//writeln('TWin32WSTaskDialog.Execute');
|
||||||
Result := inherited Execute(ADlg);
|
Result := inherited Execute(ADlg);
|
||||||
|
@ -37,7 +37,7 @@ type
|
|||||||
|
|
||||||
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
|
constructor CreateNew(AOwner: TComponent; Num: Integer = 0); override;
|
||||||
|
|
||||||
function Execute: Boolean;
|
function Execute: Integer;
|
||||||
public
|
public
|
||||||
/// the labels corresponding to the Task Dialog main elements
|
/// the labels corresponding to the Task Dialog main elements
|
||||||
Element: array[tdeContent..tdeMainInstruction] of TLabel;
|
Element: array[tdeContent..tdeMainInstruction] of TLabel;
|
||||||
@ -59,7 +59,7 @@ var
|
|||||||
TaskDialog_Translate: TTaskDialogTranslate;
|
TaskDialog_Translate: TTaskDialogTranslate;
|
||||||
|
|
||||||
|
|
||||||
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog): Boolean;
|
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog): Integer;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -143,12 +143,12 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
{ -------------- }
|
{ -------------- }
|
||||||
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog): Boolean;
|
function ExecuteLCLTaskDialog(const ADlg: TTaskDialog): Integer;
|
||||||
var
|
var
|
||||||
DlgForm: TLCLTaskDialog;
|
DlgForm: TLCLTaskDialog;
|
||||||
begin
|
begin
|
||||||
debugln('ExecuteLCLTaskDialog');
|
debugln('ExecuteLCLTaskDialog');
|
||||||
Result := False;
|
Result := -1;
|
||||||
DlgForm := TLCLTaskDialog.CreateNew(ADlg);
|
DlgForm := TLCLTaskDialog.CreateNew(ADlg);
|
||||||
try
|
try
|
||||||
Result := DlgForm.Execute;
|
Result := DlgForm.Execute;
|
||||||
@ -167,14 +167,14 @@ begin
|
|||||||
KeyPreview := True;
|
KeyPreview := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLCLTaskDialog.Execute: Boolean;
|
function TLCLTaskDialog.Execute: Integer;
|
||||||
var
|
var
|
||||||
mRes, I: Integer;
|
mRes, I: Integer;
|
||||||
aParent: HWND;
|
aParent: HWND;
|
||||||
begin
|
begin
|
||||||
debugln(['TLCLTaskDialog.Execute: Assigned(FDlg)=',Assigned(FDlg)]);
|
debugln(['TLCLTaskDialog.Execute: Assigned(FDlg)=',Assigned(FDlg)]);
|
||||||
if not Assigned(FDlg) then
|
if not Assigned(FDlg) then
|
||||||
Exit(False);
|
Exit(-1);
|
||||||
SetupControls;
|
SetupControls;
|
||||||
|
|
||||||
aParent := FDlg.ParentWindow;
|
aParent := FDlg.ParentWindow;
|
||||||
@ -193,8 +193,8 @@ begin
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
mRes := ShowModal;
|
Result := ShowModal;
|
||||||
Result := (mRes > 0);
|
//Result := (mRes > 0);
|
||||||
|
|
||||||
//ToDo implement this
|
//ToDo implement this
|
||||||
(*
|
(*
|
||||||
|
@ -106,7 +106,7 @@ type
|
|||||||
TWSTaskDialogClass = class of TWSTaskDialog;
|
TWSTaskDialogClass = class of TWSTaskDialog;
|
||||||
TWSTaskDialog = class(TWSLCLComponent)
|
TWSTaskDialog = class(TWSLCLComponent)
|
||||||
published
|
published
|
||||||
class function Execute(const ADlg: TCustomTaskDialog): Boolean; virtual;
|
class function Execute(const ADlg: TCustomTaskDialog): Integer; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ WidgetSetRegistration }
|
{ WidgetSetRegistration }
|
||||||
@ -198,7 +198,7 @@ end;
|
|||||||
|
|
||||||
{ TWSTaskDialog }
|
{ TWSTaskDialog }
|
||||||
|
|
||||||
class function TWSTaskDialog.Execute(const ADlg: TCustomTaskDialog): Boolean;
|
class function TWSTaskDialog.Execute(const ADlg: TCustomTaskDialog): Integer;
|
||||||
begin
|
begin
|
||||||
//writeln('TWSTaskDialog.Execute: Assigned(ADlg)=',Assigned(ADlg));
|
//writeln('TWSTaskDialog.Execute: Assigned(ADlg)=',Assigned(ADlg));
|
||||||
Result := ExecuteLCLTaskDialog(TTaskDialog(ADlg));
|
Result := ExecuteLCLTaskDialog(TTaskDialog(ADlg));
|
||||||
|
Loading…
Reference in New Issue
Block a user