LCL/TaskDialog: Add new property Width to override the default width.

This commit is contained in:
wp_xyz 2022-11-23 23:43:18 +01:00
parent c7164f5b58
commit 68e6168982
3 changed files with 9 additions and 4 deletions

View File

@ -632,6 +632,7 @@ type
FText: TTranslateString;
FTitle: TTranslateString;
FVerificationText: TTranslateString;
FWidth: Integer;
FOnButtonClicked: TTaskDlgClickEvent;
procedure DoOnButtonClickedHandler(Sender: PTaskDialog; AButtonID: Integer;
var ACanClose: Boolean);
@ -663,6 +664,7 @@ type
property Text: TTranslateString read FText write FText;
property Title: TTranslateString read FTitle write FTitle;
property VerificationText: TTranslateString read FVerificationText write FVerificationText;
property Width: Integer read FWidth write FWidth default 0;
property OnButtonClicked: TTaskDlgClickEvent read FOnButtonClicked write FOnButtonClicked;
end;
@ -682,6 +684,7 @@ type
property Text;
property Title;
property VerificationText;
property Width;
property OnButtonClicked;
end;

View File

@ -240,7 +240,7 @@ begin
TaskDlg.Verify := VerificationText;
ButtonID := TaskDlg.Execute(TD_COMMONBUTTONS(CommonButtons), DefBtn, TD_FLAGS(Flags), TF_DIALOGICON(MainIcon), TF_FOOTERICON(FooterIcon),
DefRB, 0, ParentWnd, tfForceNonNative in Flags, False, @DoOnButtonClickedHandler);
DefRB, FWidth, ParentWnd, tfForceNonNative in Flags, False, @DoOnButtonClickedHandler);
Result := ButtonID>=0;
FModalResult := ButtonIDToModalResult(ButtonID);

View File

@ -783,7 +783,8 @@ begin
{$ifdef MSWINDOWS}
if (WidgetSet.GetLCLCapability(lcNativeTaskDialog) = LCL_CAPABILITY_YES) and
Assigned(TaskDialogIndirect) and not aNonNative and
not (tdfQuery in aFlags) and (Selection='') then begin
not (tdfQuery in aFlags) and (Selection='') then
begin
Dialog.Emulated := False;
// use Vista/Seven TaskDialog implementation (not tdfQuery nor Selection)
FillChar(Config{%H-},sizeof(Config),0);
@ -845,13 +846,14 @@ begin
FontHeight := Dialog.Form.Font.Height;
if FontHeight = 0 then
FontHeight := Screen.SystemFont.Height;
if aWidth=0 then begin
if aWidth<=0 then begin
aWidth := Dialog.Form.Canvas.TextWidth(Inst);
if (aWidth>300) or (Dialog.Form.Canvas.TextWidth(Content)>300) or
(length(Buttons)>40) then
aWidth := 480 else
aWidth := 420;
end;
end else
if aWidth<120 then aWidth := 120;
Dialog.Form.ClientWidth := aWidth;
Dialog.Form.Height := 200;
Dialog.Form.Caption := Title;