Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Tabulator (#9) does not work in String!?


This question is answered.


Permlink Replies: 3 - Last Post: Oct 5, 2015 2:54 PM Last Post By: Ole Vander
Ole Vander

Posts: 3
Registered: 11/5/15
Tabulator (#9) does not work in String!?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 5, 2015 10:43 AM
Hej there.

I am trying to add a Tab character to my String but without any result. The Tab character is getting ignored.
eg:

procedure TForm1.FormCreate(Sender: TObject);
begin
//caption string with tab char
Button1.Caption := 'tab is not ' + #9 + Char(9) + ^I + 'working '
+ 'but space' + #32 + 'works';
//Set dialog string with tab - does not work with default
//UseLatestCommonDialogs := true -> must be false
UseLatestCommonDialogs := false;
ShowMessage('works only with ' + #9 +  'UseLatestCommonDialogs := false');
end;


Here I have just a Form and a Button. When i try to add a Tab character to the showMessage-String, I have do set UseLatestCommonDialogs to false to get this working - but i didn't find anything like this for Strings in general. Am I missing something? I read that WinAPI and VCL are maybe the ones causing this!?

Any help or hints would be much appreciated.
Best regards.

// I use Delphi 10 Seatlle on Win7 and Win10 - 32bit and 64bit - same results

Edited by: Ole Vander on Oct 5, 2015 10:45 AM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Tabulator (#9) does not work in String!? [Edit]
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 5, 2015 11:22 AM   in response to: Ole Vander in response to: Ole Vander
Ole wrote:

Here I have just a Form and a Button. When i try to add a Tab
character to the showMessage-String, I have do set
UseLatestCommonDialogs to false to get this working - but i
didn't find anything like this for Strings in general.

The problem has nothing to do with Strings themselves. The tabs do exist
in the character data. The debugger would confirm that. The issue has to
do with how the Strings are being used. Windows ignores tabs on buttons,
and UseLatestCommonDialogs controls whether ShowMessage() displays a custom
VCL Form or a Win32 TaskDialog. In the former case, the string is displayed
on a standard TLabel, which draws text using the Win32 DrawText() function
with the DT_EXPANDTABS flag enabled. In the latter case, I guess the TaskDialog
ignores tabs, too.

--
Remy Lebeau (TeamB)
Ole Vander

Posts: 3
Registered: 11/5/15
Re: Tabulator (#9) does not work in String!? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 5, 2015 2:43 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
The problem has nothing to do with Strings themselves. The tabs do exist
in the character data. The debugger would confirm that. The issue has to
do with how the Strings are being used. Windows ignores tabs on buttons,
and UseLatestCommonDialogs controls whether ShowMessage() displays a custom
VCL Form or a Win32 TaskDialog. In the former case, the string is displayed
on a standard TLabel, which draws text using the Win32 DrawText() function
with the DT_EXPANDTABS flag enabled. In the latter case, I guess the TaskDialog
ignores tabs, too.

Thank you for your response.
Is there a way to force it somehow, so i can get my tabs?
I have an quite old project here, where i migrated it to delphi 10 and there i had something like that:
textString := TStringList.Create;
textString.Add('some text with' + #9 + 'no tab' );
ListBox1.Items.AddStrings(textString);

Just a ListBox with tabbed strings.
With the older Delphi version i got my tabs, that's why i thought it could have something to do with unicode.
Are there any possibilities to force a certain behavior, like i can with UseLatestCommonDialogs regarding ListBoxes?
Is there a way to set the flag DT_EXPANDTABS to true?
Ole Vander

Posts: 3
Registered: 11/5/15
Re: Tabulator (#9) does not work in String!? [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 5, 2015 2:54 PM   in response to: Ole Vander in response to: Ole Vander
I kinda have to cancel my question.
I overlooked a property of ListBox, called TabWidth. The default value is 0 and that is obviously the problem why i didn't get my tabs.

Thanks again for your response Remy Lebeau.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02