Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to set tab stops in a TMemo Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
12-Oct-02
Category
Reporting /Printing
Language
Delphi All Versions
Views
55
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to set tab stops in a TMemo

Answer:

Solve 1:

To change the tab stops for a multiline edit control (i.e. a TMemo), send the 
EM_SetTabStops message to the component. The Tabs array indicates where the tab 
stops will be located. Since the WParam parameter to SendMessage is 1, then all tab 
stops will be set to the value passed in the Tabs array. Remember to set the 
WantTabs property of TMemo to True to enable the tabs.

1   procedure TForm1.FormCreate(Sender: TObject);
2   const
3     TabInc: LongInt = 10;
4   begin
5     SendMessage(Memo1.Handle, EM_SetTabStops, 1, Longint(@TabInc));
6   end;



Solve 2:

For a memo you use the EM_SETTABSTOPS message. Setting decimal tab stops in a memo 
control;
7   
8   procedure TScratchMain.SpeedButton2Click(Sender: TObject);
9   var
10    tabs: array[0..2] of Integer;
11  begin
12    {set first tabstop at 12, second at 24, third at 44 character position, using the
13    average width as base, converted to dialog units.4 dialog units make
14  	one average char width.}
15    tabs[0] := 12 * 4;
16    tabs[1] := 24 * 4;
17    tabs[2] := 44 * 4;
18    Memo1.Clear;
19    Memo1.Lines.Add('01234567890123456789012345678901234567890123456789');
20    Memo1.Lines.Add('Start'#9'One'#9'Two'#9'Three');
21    Memo1.Perform(EM_SETTABSTOPS, 3, LongInt(@tabs));
22    Memo1.Refresh;
23  end;


Note that the message expects the position in an arcane unit called "dialog unit", 4 of which should theoretically equal the average character width of the memos font. But using div 4 does not give the correct positioning, while using div 2 does. Don't ask me why, dialog units are really only sensible in dialogs (which are based on a dialog resource) and are relative to the font used for the dialog itself, not the controls on it.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC