TaskDialog: don't convert '\n' to LineFeed in captions:

Reason: a user might set a button or radiobutton caption to 'Save in "c:\new_folder\new.work"'
See also issue #38676
This commit is contained in:
Bart 2023-07-31 18:53:29 +02:00
parent abd09e7ad9
commit 4be2e3a717
2 changed files with 13 additions and 1 deletions

View File

@ -1757,7 +1757,10 @@ var
SetLength(ButtonCaptions,RUCount+16);
SetLength(Buttons,RUCount+16);
end;
ButtonCaptions[RUCount] := Utf8ToUtf16(StringReplace(Btns.Items[i].Caption,'\n',#10,[rfReplaceAll]));
//disable this for now: what if a caption were to be 'Save to "c:\new_folder\new.work"'' ??
//remove later
//ButtonCaptions[RUCount] := Utf8ToUtf16(StringReplace(Btns.Items[i].Caption,'\n',#10,[rfReplaceAll]));
ButtonCaptions[RUCount] := Utf8ToUtf16(Btns.Items[i].Caption);
if (Btns.Items[i] is TTaskDialogButtonItem) and (tfUseCommandLinks in ADlg.Flags) then
begin
ButtonCaptions[RUCount] := ButtonCaptions[RUCount] + Utf8ToUtf16(#10 + Btns.Items[i].CommandLinkHint);

View File

@ -137,9 +137,14 @@ const
function CR(const aText: string): string;
begin
//disable this for now: what if a caption were to be 'Save to "c:\new_folder\new.work"'' ??
//remove later
Result := AText;
{
if pos('\n', aText) = 0 then
Result := aText else
Result := StringReplace(aText, '\n', #10, [rfReplaceAll]);
}
end;
//if aText contains '\n'
@ -149,14 +154,18 @@ function NoCR(const aText: string; out aHint: String): String;
var
i: integer;
begin
//disable this for now: what if a caption were to be 'Save to "c:\new_folder\new.work"'' ??
//remove later
Result := aText;
aHint := '';
{
i := pos('\n',aText);
if (i > 0) then
begin
aHint := CR(copy(Result,i+2,maxInt));
SetLength(Result,i-1);
end;
}
end;