mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 16:58:02 +02:00
TaskDialog: start implementing CommandLinkHint property for TTaskDialog.Buttons.
For now only functional on Windows Vista+ (native dialog).
This commit is contained in:
parent
d4693029bc
commit
fff6152dde
@ -557,10 +557,13 @@ type
|
||||
|
||||
TTaskDialogButtons = class;
|
||||
|
||||
{ TTaskDialogBaseButtonItem }
|
||||
|
||||
TTaskDialogBaseButtonItem = class(TCollectionItem)
|
||||
private
|
||||
FCaption: TTranslateString;
|
||||
FClient: TCustomTaskDialog;
|
||||
FCommandLinkHint: TTranslateString;
|
||||
FModalResult: TModalResult;
|
||||
function GetDefault: Boolean;
|
||||
procedure SetCaption(const ACaption: TTranslateString);
|
||||
@ -572,6 +575,7 @@ type
|
||||
public
|
||||
constructor Create(ACollection: TCollection); override;
|
||||
property ModalResult: TModalResult read FModalResult write FModalResult;
|
||||
property CommandLinkHint: TTranslateString read FCommandLinkHint write FCommandLinkHint;
|
||||
published
|
||||
property Caption: TTranslateString read FCaption write SetCaption;
|
||||
property Default: Boolean read GetDefault write SetDefault default False;
|
||||
@ -581,6 +585,7 @@ type
|
||||
public
|
||||
constructor Create(ACollection: TCollection); override;
|
||||
published
|
||||
property CommandLinkHint;
|
||||
property ModalResult;
|
||||
end;
|
||||
|
||||
|
@ -1692,8 +1692,6 @@ var
|
||||
Footer: WideString;
|
||||
DefRB, DefBtn, RUCount: Integer;
|
||||
CommonButtons: TTaskDialogCommonButtons;
|
||||
B: TTaskDialogBaseButtonItem;
|
||||
List: TStringList;
|
||||
Flags: TTaskDialogFlags;
|
||||
Res: HRESULT;
|
||||
|
||||
@ -1706,21 +1704,24 @@ var
|
||||
TD_FOOTERICONS: array[TLCLTaskDialogFooterIcon] of integer = (
|
||||
0, 84, 99, 98, 65533, 65532);
|
||||
|
||||
procedure AddTaskDiakogButton(List: TStringList; var n: longword; firstID: integer);
|
||||
procedure AddTaskDiakogButton(Btns: TTaskDialogButtons; var n: longword; firstID: integer);
|
||||
var
|
||||
P: PChar;
|
||||
i: Integer;
|
||||
begin
|
||||
if (List.Count = 0) then
|
||||
if (Btns.Count = 0) then
|
||||
Exit;
|
||||
for i := 0 to List.Count - 1 do
|
||||
for i := 0 to Btns.Count - 1 do
|
||||
begin
|
||||
if length(ButtonCaptions)<=RUCount then
|
||||
if Length(ButtonCaptions)<=RUCount then
|
||||
begin
|
||||
SetLength(ButtonCaptions,RUCount+16);
|
||||
SetLength(Buttons,RUCount+16);
|
||||
end;
|
||||
ButtonCaptions[RUCount] := Utf8ToUtf16(StringReplace(List[i],'\n',#10,[rfReplaceAll]));
|
||||
ButtonCaptions[RUCount] := Utf8ToUtf16(StringReplace(Btns.Items[i].Caption,'\n',#10,[rfReplaceAll]));
|
||||
if (Btns.Items[i] is TTaskDialogButtonItem) and (tfUseCommandLinks in ADlg.Flags) then
|
||||
begin
|
||||
ButtonCaptions[RUCount] := ButtonCaptions[RUCount] + Utf8ToUtf16(#10 + Btns.Items[i].CommandLinkHint);
|
||||
end;
|
||||
Buttons[RUCount].nButtonID := n+firstID;
|
||||
Buttons[RUCount].pszButtonText := PWideChar(ButtonCaptions[RUCount]);
|
||||
inc(n);
|
||||
@ -1786,19 +1787,8 @@ var
|
||||
Config.nDefaultButton := DefBtn;
|
||||
|
||||
RUCount := 0;
|
||||
List := TStringList.Create;
|
||||
try
|
||||
for B in ADlg.Buttons do
|
||||
List.Add(B.Caption);
|
||||
AddTaskDiakogButton(List,Config.cButtons,TaskDialogFirstButtonIndex);
|
||||
|
||||
List.Clear;
|
||||
for B in ADlg.RadioButtons do
|
||||
List.Add(B.Caption);
|
||||
AddTaskDiakogButton(List,Config.cRadioButtons,TaskDialogFirstRadioButtonIndex);
|
||||
finally
|
||||
List.Free;
|
||||
end;
|
||||
AddTaskDiakogButton(ADlg.Buttons,Config.cButtons,TaskDialogFirstButtonIndex);
|
||||
AddTaskDiakogButton(ADlg.RadioButtons,Config.cRadioButtons,TaskDialogFirstRadioButtonIndex);
|
||||
|
||||
if (Config.cButtons > 0) then
|
||||
Config.pButtons := @Buttons[0];
|
||||
|
Loading…
Reference in New Issue
Block a user