LCLTaskDialog prevent \n conversion to LF lazarus / 31-LCL ---------------------------------------------------------------------- zamtmn · 2021-03-26 19:44 is there a way to disable this conversion? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,  LCLTaskDialog; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  td: TTaskDialog;begin  td.Content:='Save "c:\new_folder\new.work"?';  td.Execute;end; end. ---------------------------------------------------------------------- dsiders · 2021-03-26 20:01 Quote from: zamtmn on March 26, 2021, 08:44:49 pmis there a way to disable this conversion? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,  LCLTaskDialog; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  td: TTaskDialog;begin  td.Content:='Save "c:\new_folder\new.work"?';  td.Execute;end; end. That value gets passed to the Windows API, and it thinks '\n' is a new line. Have you tried quoting the backslash? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i td.Content:='Save "c:\\new_folder\\new.work"?'; ---------------------------------------------------------------------- zamtmn · 2021-03-26 20:10 No, not works(( This done not in windows, probably have to add a setting that disables this ---------------------------------------------------------------------- marcov · 2021-03-26 20:16 I would call that a bug. \n has no meaning in pascal. ---------------------------------------------------------------------- zamtmn · 2021-03-26 20:20 Quote from: marcov on March 26, 2021, 09:16:34 pmI would call that a bug. \n has no meaning in pascal. no, this documented in LCLTaskDialog Quote......................... TTaskDialog = record     /// the main title of the dialog window     // - if left void, the title of the application main form is used     Title: string;     /// the main instruction (first line on top of window)     // - any '\n' will be converted into a line feed     // - if left void, the text is taken from the current dialog icon kind     Inst: string;     /// the dialog's primary content content text     // - any '\n' will be converted into a line feed     Content: string;     /// a #13#10 or #10 separated list of custom buttons     // - they will be identified with an ID number starting at 100     // - by default, the buttons will be created at the dialog bottom, just     // like the common buttons     // - if tdfUseCommandLinks flag is set, the custom buttons will be created     // as big button in the middle of the dialog window; in this case, any     // '\n' will be converted as note text (shown with smaller text under native     // Vista/Seven TaskDialog, or as popup hint within Delphi emulation)     Buttons: string;     /// a #13#10 or #10 separated list of custom radio buttons     // - they will be identified with an ID number starting at 200     // - aRadioDef parameter can be set to define the default selected value     // - '\n' will be converted as note text (shown with smaller text under     // native Vista/Seven TaskDialog, or as popup hint within Delphi emulation)     Radios: string;     /// the expanded information content text     // - any '\n' will be converted into a line feed     // - the Delphi emulation will always show the Info content (there is no     // collapse/expand button)     Info: string;     /// the button caption to be displayed when the information is collapsed     // - not used under XP: the Delphi emulation will always show the Info content     InfoExpanded: string;     /// the button caption to be displayed when the information is expanded     // - not used under XP: the Delphi emulation will always show the Info content     InfoCollapse: string;     /// the footer content text     // - any '\n' will be converted into a line feed     Footer: string;     /// the text of the bottom most optional checkbox     Verify: string;     /// a #13#10 or #10 separated list of items to be selected     // - if set, a Combo Box will be displayed to select     // - if tdfQuery is in the flags, the combo box will be in edition mode,     // and the user will be able to edit the Query text or fill the field     // with one item of the selection     // - this selection is not handled via the Vista/Seven TaskDialog, but     // with our Delphi emulation code (via a TComboBox)     Selection: string;     /// some text to be edited     // - if tdfQuery is in the flags, will contain the default query text     // - if Selection is set, the     Query: string; ........................... ---------------------------------------------------------------------- marcov · 2021-03-26 21:55 So then it is a documented bug ? ---------------------------------------------------------------------- lucamar · 2021-03-27 02:48 Quote from: marcov on March 26, 2021, 10:55:19 pmSo then it is a documented bug ? I would call it an "unfortunate design decision" rather than a bug: it should either recognize "\\" as a escape mechanism or there should be a flag to disable it altogether. As it's, it will mangle any Windows path with directories starting with "n". In that situation one could as well use Dialogs.TTaskDialog which (IIRC) doesn't present this behaviour. ---------------------------------------------------------------------- zamtmn · 2021-03-27 16:18 I think this is a good solution: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Index: lcl/ lcltaskdialog.pas===================================================== ==============--- lcl/lcltaskdialog.pas       (revision 64866)+++ lcl/lcltaskdialog.pas       (working copy)@@ -129,7 +129,7 @@   {$IFDEF MSWINDOWS}   Windows,   {$ENDIF}-  Classes, SysUtils,+  Classes, SysUtils, StrUtils,   LazUTF8,   LCLType, LCLStrConsts, LCLIntf, InterfaceBase,   LResources, Menus, Graphics, Forms, Controls, StdCtrls, ExtCtrls, Buttons;@@ -563,9 +563,9 @@  function CR(const aText: string): string; begin-  if pos('\n', aText) = 0 then+  if pos('\', aText) = 0 then     result := aText else-    result := StringReplace(aText, '\n', #10, [rfReplaceAll]);+    result := StringsReplace(aText,['\\','\n'],['\',#10], [rfReplaceAll]); end;works with \n and \\ it is worth creating a bug report? ---------------------------------------------------------------------- marcov · 2021-03-27 20:07 A good solution needs no escaping. An user can pass it well-formed pascal strings, and the widgetset-whatever code escapes it to pass to legacy OS services that expect escaping. ---------------------------------------------------------------------- zamtmn · 2021-03-27 22:24 I proceed from what is. I just added \\ ---------------------------------------------------------------------- zamtmn · 2021-03-28 12:36 Quote from: jamie on March 27, 2021, 06:08:31 pmSo you want to cripple the Window users? what if I want all of that in there ? tell me more, what do you mean? Quote from: marcov on March 27, 2021, 09:07:01 pmA good solution needs no escaping. An user can pass it well-formed pascal strings, and the widgetset-whatever code escapes it to pass to legacy OS services that expect escaping. If I were doing something new, I would do something new. Here you need to leave compatibility with existing code, but add new functionality