Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab Stops and RichTextBox 1

Status
Not open for further replies.

rdavis

Programmer
Apr 29, 2002
157
US
Is there a way to set the Tab Stops in a RichTextBox?

Thanks

Rob
 
One approach that you might want to try is to use the SendMessage API with the EM_SETTABSTOPS message, and an array containing the location of the tab stops:
The code would look something like the following, which is for a text box.
Code:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const EM_SETTABSTOPS = &HCB

Private Sub SetTabs

   Dim TabStops(2) As Long
 
   TabStops(0) = 90
   TabStops(1) = 130
   TabStops(2) = 185
 
   Call SendMessage(control.hWnd, EM_SETTABSTOPS, 3, TabStops(0))
   control.Refresh

End Sub

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks Cajun for pointing me in the right direction. I was looking at the Richedit Control messages and did not see one at first, but I did not look at the Edit Control messages. Thanks


Rob
 
Yes you can. I was looking at the RichTextBox Messages to see if you can do it, but it is descibe in the Edit Control Messages and it can be used for Edit and RichText Edit controls



Rob
 
I meant using RTF tags embedded in the text - might be easier than doing direct Windows programming
 
How would you do that? Above looks alot easier.


Rob
 
I don't know but I thought somebody else might. If you use the TextRTF property you can see the raw marked up text. If you see the RTF specification in the MSDNL Specifications node you can see an army of tags ( including an tags to color individual characters ) but the problem is that nowhere I have been able to find a tuturial for RichTextBox RTF.
 
You probably won't have found a tutorial on the tags for VB's RichTextBox control because the whole point of the control is to hide all that 'nastiness' away behind a nice set object methods and properties. Of course, MS decided exactly what methods and properties to make available and, as with many of their controls, sacrificed a certain amount of flexibility for ease-of-use. In fact, it is worse than that, because MS have not updated the OCX from version 1.0 even though the underlying control is now at version 3.0
 
How is it possible for an .ocx to have a different version no. from the "underlying control". Actually what I'm trying to find out whether one can enter RTF in the control itself and then watch the markup magically disappear leaving only the formatted text visible?
 
Um, because of Microsoft and their naming conventions. The Common Controls OCX is a set of VB controls which wrap the API of the common controls DLLs which themselves contain a set of Windows controls, giving you a nice COM interface to those controls' API. The underlying Windows control for VB's RichTextBox is the Rich Edit control. Rich Edit is now up to version 4.1 (which, for backwards compatibility, contains an emulator for Rich Edit 1.0), whilst the features implemented and supported by VB's RichTextBox are only those of (the much more limited) Rich Edit 1.0

For more information than you are likely to want on Rich Edit:
 
Thanks for the clear answer. I'll check out the link but do you have any info. on the other part of the question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top