Button Bar, Ruler Bar and Status Bar
Word processor users expect a strip of formatting buttons above the text, a ruler for indents and tabs and a status line that tells them where they are. TX Text Control ActiveX ships all three as separate controls in the same OCX file as TXTextControl: TXButtonBar, TXRulerBar and TXStatusBar. Once you connect them, they show the attributes at the input position and change them without any further code.
The sections below describe what each bar shows, how to connect it, how to arrange its buttons and fields and how the TXWords sample sets them up and hides them. To place the controls on a form for the first time, follow Creating a Simple Word Processor.
What the Three Bars Show
The screenshots show version 34.0. In the main window of TXWords, the button bar sits below the menu and the sample's own toolbar, the horizontal ruler below it, the vertical ruler on the left and the status bar at the bottom:

TXButtonBar
A TXButtonBar offers combo boxes and buttons for the formatting of the selected text: the formatting style, the font name and size, bold, italic and underline, paragraph alignment, lists, tabs and a zoom box. It always shows the attributes of the current selection, so a user sees at a glance which font and alignment the text has.

TXRulerBar
A TXRulerBar sets paragraph attributes such as indents and tab stops with the mouse, and the horizontal alignment of table cells. Its Direction property decides whether it is a horizontal ruler (0 - txHorizontal, the default) or a vertical ruler (1 - txVertical). An application that wants both uses two TXRulerBar controls.

When the input position is in a table, the ruler shows markers at the cell boundaries:

The input position is the place in the text where typed characters appear, marked by the blinking cursor. Selections, Clipboard and Undo explains it in detail.
TXStatusBar
A TXStatusBar shows the section, page, line and column number of the input position, the number of sections and pages, the language of the selected text and the zoom factor. It can also display an info text of your own, which you set with its Text property.

Connect the Bars to TXTextControl
A bar on a form does nothing until TXTextControl knows about it. Four properties of TXTextControl take the window handle of a bar, which the bar's hWnd property returns:
Property of TXTextControl | Connects |
|---|---|
| ButtonBarHandle | A TXButtonBar |
| RulerHandle | A TXRulerBar as the horizontal ruler |
| VerticalRulerHandle | A TXRulerBar as the vertical ruler (since version 13.0) |
| StatusBarHandle | A TXStatusBar |
All four are run-time only: you can't set them in the Properties window, so you assign them in code, usually when the form loads. TXWords names its controls TXButtonBar1, TXRuler1 (horizontal), TXRuler2 (vertical) and TXStatusBar1, and connects them in a procedure that Form_Load calls:
Private Sub setWindowLayout(rtl As Boolean)
TXTextControl1.RightToLeft = rtl
TXRuler1.RightToLeft = rtl
TXRuler2.RightToLeft = rtl
TXButtonBar1.RightToLeft = rtl
TXStatusBar1.RightToLeft = rtl
' Connect to rulers, button bar and status bar
TXTextControl1.RulerHandle = TXRuler1.hwnd
TXTextControl1.VerticalRulerHandle = TXRuler2.hwnd
TXTextControl1.ButtonBarHandle = TXButtonBar1.hwnd
TXTextControl1.StatusBarHandle = TXStatusBar1.hwnd
End Sub
The code works as follows:
- The
RightToLeftproperties of TXRulerBar, TXButtonBar and TXStatusBar mirror the bars for right-to-left languages. TXWords passesTruewhen the Windows reading direction is right to left. - Setting
RightToLeftat run time recreates the bar's window, and the new window must be assigned toTXTextControlagain. This is why TXWords connects the bars after it has set the direction, and again every time the user changes View > Window Layout. - Each
...Handleproperty receives thehWndof one bar, for example hWnd ofTXRuler1.
You don't have to use all four bars. Connect only the ones on your form.
Connect the Bars in Microsoft Access
In a Microsoft Access form, the ConnectTools event of TXTextControl occurs after all text controls and bars have been created and are ready to be connected. The reference describes two steps: set each handle property to 1 in the form's Load event, then assign the real hWnd values in the ConnectTools event procedure.
Arrange the Buttons of the Button Bar
Each element of the button bar has a Pos... property, such as PosFontBold or PosZoom. Its value is the element's position number, starting at 1:
- 0 hides the element.
- Adding 1000 to a position number creates a gap between the element and the element before it.
- Adding 2000 creates a gap with a vertical group mark.
By default, the bar shows the style, font name and size boxes, bold, italic, underline, the four alignment buttons, the numbered, bulleted and structured list buttons, the tab type button and the control characters button. Strikethrough, subscript, superscript, the grow and shrink font buttons, the indent buttons, the text direction buttons, the four single tab buttons, the XML combo boxes and the zoom box are hidden until you give them a position. The PosControlChars page lists which property belongs to which element.
TXWords sets the positions at design time in the Properties window, where Visual Basic stores them in frmMain.frm:
| Position | Element | Property | Value in TXWords |
|---|---|---|---|
| 1 | Style box | PosStyle | 1 |
| 2, 3 | Font name and size boxes | PosFontName, PosFontSize | 2, 3 |
| 4 to 6 | Bold, italic, underline | PosFontBold, PosFontItalic, PosFontUnderline | 2004, 5, 6 |
| 7, 8 | Grow and shrink font | PosGrowFont, PosShrinkFont | 7, 8 |
| 9 to 12 | Left, right, centered, justified | PosParaLeft, PosParaRight, PosParaCentered, PosParaJustified | 2009, 10, 11, 12 |
| 13, 14 | Left to right, right to left | PosLeftToRight, PosRightToLeft | 2013, 14 |
| 15 | Zoom box | PosZoom | 2015 |
| 16 to 18 | Numbered, bulleted, structured list | PosListNumbered, PosListBulleted, PosListStructured | 2016, 17, 18 |
| 19, 20 | Increase and decrease indent | PosIncreaseIndent, PosDecreaseIndent | 19, 20 |
| 21 | Tab type | PosTabSelect | 2021 |
| 22 | Control characters | PosControlChars | 22 |
The single tab buttons, strikethrough, subscript, superscript and the XML combo boxes have the value 0 and stay hidden.
The Pos... properties can also be set in code. To take the zoom box and the control characters button off the bar, set their positions to 0:
Private Sub Form_Load()
' Hide the zoom box and the control characters button
TXButtonBar1.PosZoom = 0
TXButtonBar1.PosControlChars = 0
TXTextControl1.ButtonBarHandle = TXButtonBar1.hWnd
End Sub
To keep the button bar visible but stop it from changing the text, set its ReadOnly property to True (since version 24.0). It still shows the attributes of the selection.
Set Up the Rulers
The same TXRulerBar control serves as the horizontal and the vertical ruler. Its properties decide what it shows and what the user can change with it:
| Property | What it sets | TXWords |
|---|---|---|
| Direction | 0 - txHorizontal or 1 - txVertical | 0 for TXRuler1, 1 for TXRuler2 |
| ScaleUnits | The scale: 0 for mm, 1 for cm, 2 for inch | 0 |
| EnablePageMargins | Whether the user can set the page margins with the ruler (default True) | True |
| FormulaMode | Whether the ruler shows cell references in a table: 0 - rlNone, 1 - rlAuto (only in a cell that contains a formula) or 2 - rlAlways | 1 |
| ReadOnly | Shows the attributes but doesn't let the user change them | False |
FormulaMode shows the references in the A1 or the R1C1 notation, depending on the FormulaReferenceStyle property of TXTextControl, and has no effect when the ruler's Appearance is tx3D. Using Formulas in Table Cells describes formulas in table cells.
In TXWords, both rulers are aligned with the Visual Basic Align property: the horizontal ruler to the top, the vertical ruler to the left, or to the right when the window layout is right to left.
Choose the Status Bar Fields
Each field of the status bar has a Show... property that turns it on or off and, for the numbered fields, a Text... property with the label in front of the number:
| Field | Shown by | Label | TXWords label |
|---|---|---|---|
| Section number | ShowSection | TextSection | "Section " |
| Number of sections | ShowSectionCounter | TextSectionCounter | "/" |
| Page number | ShowPage, PageMode | TextPage | "Page " |
| Number of pages | ShowPageCounter | TextPageCounter | "/" |
| Line number | ShowLine | TextLine | "Line " |
| Column number | ShowColumn | TextColumn | "Col " |
| Language of the selection | ShowLocale | -- | -- |
| Zoom factor as a track bar | ShowZoomTrackBar | -- | -- |
TXWords sets all Show... properties to True, which gives the status bar in the screenshot above. ShowZoomTrackBar replaces the plain zoom number with a track bar that shows the zoom factor and lets the user set it.
PageMode controls the page field further: 0 hides it, 1 always shows it and 2 shows it only when the ViewMode of the connected TXTextControl is Page View. TXWords uses 2. Text Formatting and Views explains the view modes.
The labels are ordinary strings, so you can translate them. This code sets German labels and turns off the section fields:
Private Sub Form_Load()
With TXStatusBar1
.ShowSection = False
.ShowSectionCounter = False
.TextPage = "Seite "
.TextPageCounter = " von "
.TextLine = "Zeile "
.TextColumn = "Spalte "
End With
TXTextControl1.StatusBarHandle = TXStatusBar1.hWnd
End Sub
Show and Hide the Bars
The View menu of TXWords has one item per bar: Tool Bar (the sample's own Windows toolbar), Button Bar, Horizontal Ruler, Vertical Ruler and Status Bar. A check mark shows which bars are visible.

Each item switches the Visual Basic Visible property of its bar, toggles the check mark and resizes TXTextControl to fill the space. For the button bar, the code is:
Private Sub mnuView_ButtonBar_Click()
ViewButtonBarProc
mnuView_ButtonBar.Checked = Not mnuView_ButtonBar.Checked
End Sub
Sub ViewButtonBarProc()
TXButtonBar1.Visible = Not TXButtonBar1.Visible
Resize
End Sub
The Resize procedure of TXWords adds up the heights of the visible bars and of the sample's toolbar and the width of the vertical ruler, and sizes TXTextControl to the rest of the form. A hidden bar counts as 0. The rulers and the status bar work the same way with TXRuler1, TXRuler2 and TXStatusBar1. Creating a Simple Word Processor shows a simpler Form_Resize procedure for bars that are always visible.
Change the Look and the Language
All three bars have an Appearance property for their paint style, such as flat, 3D, Windows XP look or a color scheme that follows the system colors: TXButtonBar, TXRulerBar and TXStatusBar. The button bar has a second property, Style, for the paint style of its buttons. With the color scheme appearance, a DisplayColor property sets individual colors, for example of the TXRulerBar (since version 15.1). TXWords uses the color scheme for the rulers and the button bar, the Windows XP style for the buttons and the vertical color scheme (4 - sbVerticalColorScheme) for the status bar.
The bars display resources, such as the status bar texts and the images of the bold, italic and underline buttons, in a language of their own. Setting the language or the resource library of TXTextControl doesn't change them: set the Language or ResourceFile property of each bar, for example Language and ResourceFile of TXButtonBar. English and German are built in. Resources and Localization describes how TX Text Control chooses the language and how to build a resource library.
Key Members
| Member | Description |
|---|---|
| TXTextControl.ButtonBarHandle | Connects a TXButtonBar to the text control. |
| TXTextControl.RulerHandle | Connects a TXRulerBar as the horizontal ruler. |
| TXTextControl.VerticalRulerHandle | Connects a TXRulerBar as the vertical ruler. |
| TXTextControl.StatusBarHandle | Connects a TXStatusBar to the text control. |
| TXTextControl.ConnectTools | Microsoft Access only: occurs when all controls can be connected. |
| TXButtonBar.PosControlChars | Position of the control characters button, and the rules for all Pos... properties. |
| TXButtonBar.ReadOnly | Shows the formatting without letting the user change it. |
| TXRulerBar.Direction | Makes a ruler horizontal or vertical. |
| TXRulerBar.ScaleUnits | The scale of the ruler: mm, cm or inch. |
| TXRulerBar.FormulaMode | Shows cell references when the input position is in a table cell. |
| TXStatusBar.PageMode | Hides the page field, shows it always or only in page view. |
| TXStatusBar.ShowZoomTrackBar | Shows a track bar instead of a number for the zoom factor. |
| TXStatusBar.Text | The info text of the status bar. |