mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-08 09:58:27 +02:00
Refactoring TTaskDialog: switch over to the new code, remove dependency on deprecated unit LCLTaskDialog.
This commit is contained in:
parent
ca1e231417
commit
b9634c255d
@ -26,7 +26,7 @@ uses
|
|||||||
// LCL
|
// LCL
|
||||||
LMessages, LResources, LCLIntf, InterfaceBase, LCLStrConsts, LCLType,
|
LMessages, LResources, LCLIntf, InterfaceBase, LCLStrConsts, LCLType,
|
||||||
Forms, Controls, Themes, Graphics, Buttons, ButtonPanel, StdCtrls,
|
Forms, Controls, Themes, Graphics, Buttons, ButtonPanel, StdCtrls,
|
||||||
ExtCtrls, LCLClasses, ClipBrd, Menus, LCLTaskDialog, DialogRes,
|
ExtCtrls, LCLClasses, ClipBrd, Menus, {LCLTaskDialog,} DialogRes,
|
||||||
// LazUtils
|
// LazUtils
|
||||||
GraphType, FileUtil, LazFileUtils, LazStringUtils, LazLoggerBase;
|
GraphType, FileUtil, LazFileUtils, LazStringUtils, LazLoggerBase;
|
||||||
|
|
||||||
@ -635,8 +635,8 @@ type
|
|||||||
FTitle: TTranslateString;
|
FTitle: TTranslateString;
|
||||||
FVerificationText: TTranslateString;
|
FVerificationText: TTranslateString;
|
||||||
FOnButtonClicked: TTaskDlgClickEvent;
|
FOnButtonClicked: TTaskDlgClickEvent;
|
||||||
procedure DoOnButtonClickedHandler(Sender: PTaskDialog; AButtonID: Integer;
|
//procedure DoOnButtonClickedHandler(Sender: PTaskDialog; AButtonID: Integer;
|
||||||
var ACanClose: Boolean);
|
// var ACanClose: Boolean);
|
||||||
procedure SetButtons(const Value: TTaskDialogButtons);
|
procedure SetButtons(const Value: TTaskDialogButtons);
|
||||||
procedure SetRadioButtons(const Value: TTaskDialogButtons);
|
procedure SetRadioButtons(const Value: TTaskDialogButtons);
|
||||||
protected
|
protected
|
||||||
|
@ -134,91 +134,91 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomTaskDialog.DoExecute(ParentWnd: HWND): Boolean;
|
function TCustomTaskDialog.DoExecute(ParentWnd: HWND): Boolean;
|
||||||
function TD_COMMONBUTTONS(const aButtons: TTaskDialogCommonButtons): LCLTaskDialog.TCommonButtons;
|
//function TD_COMMONBUTTONS(const aButtons: TTaskDialogCommonButtons): LCLTaskDialog.TCommonButtons;
|
||||||
begin
|
//begin
|
||||||
Result := [];
|
// Result := [];
|
||||||
if tcbOk in aButtons then
|
// if tcbOk in aButtons then
|
||||||
Result := Result + [cbOK];
|
// Result := Result + [cbOK];
|
||||||
if tcbYes in aButtons then
|
// if tcbYes in aButtons then
|
||||||
Result := Result + [cbYes];
|
// Result := Result + [cbYes];
|
||||||
if tcbNo in aButtons then
|
// if tcbNo in aButtons then
|
||||||
Result := Result + [cbNo];
|
// Result := Result + [cbNo];
|
||||||
if tcbCancel in aButtons then
|
// if tcbCancel in aButtons then
|
||||||
Result := Result + [cbCancel];
|
// Result := Result + [cbCancel];
|
||||||
if tcbRetry in aButtons then
|
// if tcbRetry in aButtons then
|
||||||
Result := Result + [cbRetry];
|
// Result := Result + [cbRetry];
|
||||||
if tcbClose in aButtons then
|
// if tcbClose in aButtons then
|
||||||
Result := Result + [cbClose];
|
// Result := Result + [cbClose];
|
||||||
end;
|
//end;
|
||||||
|
|
||||||
function TD_FLAGS(const aTaskFlags: TTaskDialogFlags): LCLTaskDialog.TTaskDialogFlags;
|
//function TD_FLAGS(const aTaskFlags: TTaskDialogFlags): LCLTaskDialog.TTaskDialogFlags;
|
||||||
begin
|
//begin
|
||||||
Result := [];
|
// Result := [];
|
||||||
if tfEnableHyperlinks in aTaskFlags then
|
// if tfEnableHyperlinks in aTaskFlags then
|
||||||
Result := Result + [tdfEnableHyperlinks];
|
// Result := Result + [tdfEnableHyperlinks];
|
||||||
if tfUseHiconMain in aTaskFlags then
|
// if tfUseHiconMain in aTaskFlags then
|
||||||
Result := Result + [tdfUseHIconMain];
|
// Result := Result + [tdfUseHIconMain];
|
||||||
if tfUseHiconFooter in aTaskFlags then
|
// if tfUseHiconFooter in aTaskFlags then
|
||||||
Result := Result + [tdfUseHIconFooter];
|
// Result := Result + [tdfUseHIconFooter];
|
||||||
if tfAllowDialogCancellation in aTaskFlags then
|
// if tfAllowDialogCancellation in aTaskFlags then
|
||||||
Result := Result + [tdfAllowDialogCancellation];
|
// Result := Result + [tdfAllowDialogCancellation];
|
||||||
if tfUseCommandLinks in aTaskFlags then
|
// if tfUseCommandLinks in aTaskFlags then
|
||||||
Result := Result + [tdfUseCommandLinks];
|
// Result := Result + [tdfUseCommandLinks];
|
||||||
if tfUseCommandLinksNoIcon in aTaskFlags then
|
// if tfUseCommandLinksNoIcon in aTaskFlags then
|
||||||
Result := Result + [tdfUseCommandLinksNoIcon];
|
// Result := Result + [tdfUseCommandLinksNoIcon];
|
||||||
if tfExpandFooterArea in aTaskFlags then
|
// if tfExpandFooterArea in aTaskFlags then
|
||||||
Result := Result + [tdfExpandFooterArea];
|
// Result := Result + [tdfExpandFooterArea];
|
||||||
if tfExpandedByDefault in aTaskFlags then
|
// if tfExpandedByDefault in aTaskFlags then
|
||||||
Result := Result + [tdfExpandByDefault];
|
// Result := Result + [tdfExpandByDefault];
|
||||||
if tfVerificationFlagChecked in aTaskFlags then
|
// if tfVerificationFlagChecked in aTaskFlags then
|
||||||
Result := Result + [tdfVerificationFlagChecked];
|
// Result := Result + [tdfVerificationFlagChecked];
|
||||||
if tfShowProgressBar in aTaskFlags then
|
// if tfShowProgressBar in aTaskFlags then
|
||||||
Result := Result + [tdfShowProgressBar];
|
// Result := Result + [tdfShowProgressBar];
|
||||||
if tfShowMarqueeProgressBar in aTaskFlags then
|
// if tfShowMarqueeProgressBar in aTaskFlags then
|
||||||
Result := Result + [tdfShowMarqueeProgressBar];
|
// Result := Result + [tdfShowMarqueeProgressBar];
|
||||||
if tfCallbackTimer in aTaskFlags then
|
// if tfCallbackTimer in aTaskFlags then
|
||||||
Result := Result + [tdfCallbackTimer];
|
// Result := Result + [tdfCallbackTimer];
|
||||||
if tfPositionRelativeToWindow in aTaskFlags then
|
// if tfPositionRelativeToWindow in aTaskFlags then
|
||||||
Result := Result + [tdfPositionRelativeToWindow];
|
// Result := Result + [tdfPositionRelativeToWindow];
|
||||||
if tfRtlLayout in aTaskFlags then
|
// if tfRtlLayout in aTaskFlags then
|
||||||
Result := Result + [tdfRtlLayout];
|
// Result := Result + [tdfRtlLayout];
|
||||||
if tfNoDefaultRadioButton in aTaskFlags then
|
// if tfNoDefaultRadioButton in aTaskFlags then
|
||||||
Result := Result + [tdfNoDefaultRadioButton];
|
// Result := Result + [tdfNoDefaultRadioButton];
|
||||||
if tfCanBeMinimized in aTaskFlags then
|
// if tfCanBeMinimized in aTaskFlags then
|
||||||
Result := Result + [tdfCanBeMinimized];
|
// Result := Result + [tdfCanBeMinimized];
|
||||||
if tfNoSetForeGround in aTaskFlags then
|
// if tfNoSetForeGround in aTaskFlags then
|
||||||
Result := Result + [tdfNoSetForeGround];
|
// Result := Result + [tdfNoSetForeGround];
|
||||||
if tfSizeToContent in aTaskFlags then
|
// if tfSizeToContent in aTaskFlags then
|
||||||
Result := Result + [tdfSizeToContent];
|
// Result := Result + [tdfSizeToContent];
|
||||||
end;
|
//end;
|
||||||
|
|
||||||
function TF_DIALOGICON(const aIcon: TTaskDialogIcon): LCLTaskDialog.TTaskDialogIcon;
|
//function TF_DIALOGICON(const aIcon: TTaskDialogIcon): LCLTaskDialog.TTaskDialogIcon;
|
||||||
begin
|
//begin
|
||||||
case aIcon of
|
// case aIcon of
|
||||||
tdiWarning: Result := LCLTaskDialog.TTaskDialogIcon.tiWarning;
|
// tdiWarning: Result := LCLTaskDialog.TTaskDialogIcon.tiWarning;
|
||||||
tdiError: Result := LCLTaskDialog.TTaskDialogIcon.tiError;
|
// tdiError: Result := LCLTaskDialog.TTaskDialogIcon.tiError;
|
||||||
tdiInformation: Result := LCLTaskDialog.TTaskDialogIcon.tiInformation;
|
// tdiInformation: Result := LCLTaskDialog.TTaskDialogIcon.tiInformation;
|
||||||
tdiShield: Result := LCLTaskDialog.TTaskDialogIcon.tiShield;
|
// tdiShield: Result := LCLTaskDialog.TTaskDialogIcon.tiShield;
|
||||||
tdiQuestion: Result := LCLTaskDialog.TTaskDialogIcon.tiQuestion;
|
// tdiQuestion: Result := LCLTaskDialog.TTaskDialogIcon.tiQuestion;
|
||||||
else
|
// else
|
||||||
Result := LCLTaskDialog.TTaskDialogIcon.tiBlank;
|
// Result := LCLTaskDialog.TTaskDialogIcon.tiBlank;
|
||||||
end;
|
// end;
|
||||||
end;
|
//end;
|
||||||
|
//
|
||||||
function TF_FOOTERICON(const aIcon: TTaskDialogIcon): LCLTaskDialog.TTaskDialogFooterIcon;
|
//function TF_FOOTERICON(const aIcon: TTaskDialogIcon): LCLTaskDialog.TTaskDialogFooterIcon;
|
||||||
begin
|
//begin
|
||||||
case aIcon of
|
// case aIcon of
|
||||||
tdiWarning: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiWarning;
|
// tdiWarning: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiWarning;
|
||||||
tdiError: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiError;
|
// tdiError: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiError;
|
||||||
tdiInformation: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiInformation;
|
// tdiInformation: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiInformation;
|
||||||
tdiShield: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiShield;
|
// tdiShield: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiShield;
|
||||||
tdiQuestion: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiQuestion;
|
// tdiQuestion: Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiQuestion;
|
||||||
else
|
// else
|
||||||
Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiBlank;
|
// Result := LCLTaskDialog.TTaskDialogFooterIcon.tfiBlank;
|
||||||
end;
|
// end;
|
||||||
end;
|
//end;
|
||||||
var
|
var
|
||||||
TaskDlg: LCLTaskDialog.TTaskDialog;
|
//TaskDlg: LCLTaskDialog.TTaskDialog;
|
||||||
DefRB, DefBtn: TModalResult;
|
DefRB, DefBtn: TModalResult;
|
||||||
B: TTaskDialogBaseButtonItem;
|
B: TTaskDialogBaseButtonItem;
|
||||||
ButtonID, ARadioRes: Integer;
|
ButtonID, ARadioRes: Integer;
|
||||||
@ -230,23 +230,23 @@ begin
|
|||||||
//Result := TWSTaskDialogClass(WidgetSetClass).Execute(Self);
|
//Result := TWSTaskDialogClass(WidgetSetClass).Execute(Self);
|
||||||
|
|
||||||
|
|
||||||
//temporary show new, then old dialog, both in emulated mode (regardless of Flags)
|
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
//LCLTaskDialog.TaskDialogIndirect := nil;
|
|
||||||
{$ENDIF}
|
|
||||||
ButtonID := TWSTaskDialogClass(WidgetSetClass).Execute(Self, ParentWnd, ARadioRes);
|
ButtonID := TWSTaskDialogClass(WidgetSetClass).Execute(Self, ParentWnd, ARadioRes);
|
||||||
FModalResult := ButtonIDToModalResult(ButtonID);
|
FModalResult := ButtonIDToModalResult(ButtonID);
|
||||||
Result := (ButtonID >= 0);
|
Result := (ButtonID >= 0);
|
||||||
|
if (ARadioRes >= TaskDialogFirstRadioButtonIndex) and (aRadioRes-TaskDialogFirstRadioButtonIndex < RadioButtons.Count) then
|
||||||
|
FRadioButton := RadioButtons[ARadioRes-TaskDialogFirstRadioButtonIndex] as TTaskDialogRadioButtonItem
|
||||||
|
else
|
||||||
|
FRadioButton := nil;
|
||||||
debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',ButtonID,', Result=',Result]);
|
debugln(['TWSTaskDialogClass(WidgetSetClass).Execute(Self)=',ButtonID,', Result=',Result]);
|
||||||
debugln(['New: ButtonID=',ButtonID]);
|
debugln([' ButtonID=',ButtonID]);
|
||||||
debugln(['New: FModalResult=',FModalResult]);
|
debugln([' FModalResult=',FModalResult]);
|
||||||
debugln(['New: VerifyChecked=',tfVerificationFlagChecked in FFlags]);
|
debugln([' VerifyChecked=',tfVerificationFlagChecked in FFlags]);
|
||||||
debugln(['New: ARadioRes=',ARadioRes]);
|
debugln([' ARadioRes=',ARadioRes]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(*
|
||||||
FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0);
|
FillChar(TaskDlg, SizeOf(LCLTaskDialog.TTaskDialog), 0);
|
||||||
|
|
||||||
if RadioButtons.DefaultButton<> nil then
|
if RadioButtons.DefaultButton<> nil then
|
||||||
@ -290,6 +290,7 @@ begin
|
|||||||
Include(FFlags, tfVerificationFlagChecked)
|
Include(FFlags, tfVerificationFlagChecked)
|
||||||
else
|
else
|
||||||
Exclude(FFlags, tfVerificationFlagChecked)
|
Exclude(FFlags, tfVerificationFlagChecked)
|
||||||
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomTaskDialog.DoOnButtonClicked(AModalResult: Integer;
|
procedure TCustomTaskDialog.DoOnButtonClicked(AModalResult: Integer;
|
||||||
@ -299,11 +300,11 @@ begin
|
|||||||
FOnButtonClicked(Self, AModalResult, ACanClose);
|
FOnButtonClicked(Self, AModalResult, ACanClose);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomTaskDialog.DoOnButtonClickedHandler(Sender: PTaskDialog;
|
//procedure TCustomTaskDialog.DoOnButtonClickedHandler(Sender: PTaskDialog;
|
||||||
AButtonID: integer; var ACanClose: Boolean);
|
// AButtonID: integer; var ACanClose: Boolean);
|
||||||
begin
|
//begin
|
||||||
DoOnButtonClicked(ButtonIDToModalResult(AButtonID), ACanClose)
|
// DoOnButtonClicked(ButtonIDToModalResult(AButtonID), ACanClose)
|
||||||
end;
|
//end;
|
||||||
|
|
||||||
function TCustomTaskDialog.Execute(ParentWnd: HWND): Boolean;
|
function TCustomTaskDialog.Execute(ParentWnd: HWND): Boolean;
|
||||||
begin
|
begin
|
||||||
|
@ -1663,14 +1663,15 @@ begin
|
|||||||
|
|
||||||
case uNotification of
|
case uNotification of
|
||||||
TDN_BUTTON_CLICKED:
|
TDN_BUTTON_CLICKED:
|
||||||
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
|
||||||
if Assigned(Dlg.OnButtonClicked) then
|
|
||||||
begin
|
begin
|
||||||
CanClose := True;
|
Assert((Dlg is TCustomTaskDialog),'TaskDialogCallbackProc: dwRefData is NOT a TCustomTaskDialog');
|
||||||
//ptd^.Dialog.OnButtonClicked(ptd,wParam,CanClose);
|
if Assigned(Dlg.OnButtonClicked) then
|
||||||
Dlg.OnButtonClicked(Dlg, Dlg.ButtonIDToModalResult(wParam), CanClose);
|
begin
|
||||||
if not CanClose then
|
CanClose := True;
|
||||||
Result := S_FALSE;
|
Dlg.OnButtonClicked(Dlg, Dlg.ButtonIDToModalResult(wParam), CanClose);
|
||||||
|
if not CanClose then
|
||||||
|
Result := S_FALSE;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user