# A Word Processor

> TXWords, the VB6 word processor sample, sets up pages with SectionFormatDialog, prints with PrintDialog, previews pages, finds text and sets frames and colors.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control ActiveX > Document Editor > A Word Processor
- **2017 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/word-processor/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/word-processor/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/document-editor/word-processor/llms-full.txt

---

TXWords is the word processor sample of TX Text Control ActiveX, written in Visual Basic 6. Its main form holds a `TXTextControl` together with a button bar, two rulers and a status bar, and its menus reach almost every feature of the control. Most of its commands are a single call of a `TXTextControl` method that opens a built-in dialog box.

The source code of this example is in the *Samples\\vb6\\TXWords* sample source directory. The sections below describe the commands for page setup, printing, searching, paragraph frames and colors, and the members they use. The other pages of this section take up the rest of TXWords, such as tables, fields, track changes and protection.

![The TXWords sample of TX Text Control ActiveX 34.0 with a TXButtonBar, a horizontal and a vertical TXRulerBar, a TXTextControl in page view and a TXStatusBar connected to each other.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/txwords-main-window.bc3ec667.webp)

### How TXWords Is Organized

TXWords is a single-document application. The form *frmMain.frm* contains the controls, the menus and a Windows toolbar, and the event handlers of the menu items call `TXTextControl` directly. The module *tx.bas* declares constants for the parameters of these calls, such as `CLIP_COPY` for [Clip](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/clip-method/llms-full.txt) or `SECTFMTDLG_PAGE` for [SectionFormatDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/sectionformatdialog-method/llms-full.txt). The module *File.bas* loads and saves files, and further forms hold the print preview, the review of tracked changes, the comments window and other dialog boxes of the sample.

### Set Up the Page

**File** > **Page Setup...** opens the built-in **Page Setup** dialog box, in which the user sets the page size, the orientation and the page margins:

```vbscript
Private Sub mnuFile_PageSetup_Click()
    TXTextControl1.SectionFormatDialog SECTFMTDLG_PAGE
End Sub
```

`SECTFMTDLG_PAGE` is 0 and opens the first tab of the dialog box. The other tabs set headers and footers, columns and page borders, which the **Format** menu opens. [Sections and Page Setup](https://docs.textcontrol.com/tx-text-control-activex/document-editor/sections/#let-users-set-up-pages) describes all four tabs.

![The Margins and Paper tab of the built-in Page Setup dialog box of TXTextControl with the page margins, the paper format and size, the orientation, the section start and Apply to.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/page-setup-margins-paper.f616920e.webp)

### Print and Preview the Document

**File** > **Print...** and the **Print** button of the toolbar call [PrintDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/printdialog-method/llms-full.txt), which opens the system print dialog box and prints the document. Its parameter is the name of the print job:

```vbscript
Private Sub mnuFile_Print_Click()
    TXTextControl1.PrintDialog "TX Text Control Words"
End Sub
```

**File** > **Print Preview** opens the form *PrintPreview.frm*. It prints one page at a time into a Picture Box with the [PrintDevice](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/printdevice-property/llms-full.txt), [PrintZoom](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/printzoom-property/llms-full.txt) and [PrintPage](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/printpage-method/llms-full.txt) members. [Printing](https://docs.textcontrol.com/tx-text-control-activex/document-editor/printing/llms-full.txt) describes printing page by page and the print preview in detail.

### Search and Replace Text

`TXTextControl` does all the searching and replacing itself. Call the [FindReplace](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/findreplace-method/llms-full.txt) method with 1 for the **Find** dialog box or 2 for the **Replace** dialog box. TXWords declares the values as `FINDREPL_FIND` and `FINDREPL_REPLACE` and calls them from **Edit** > **Find...** and **Edit** > **Replace...**:

```vbscript
Private Sub mnuEdit_Find_Click()
    TXTextControl1.FindReplace FINDREPL_FIND
End Sub

Private Sub mnuEdit_Replace_Click()
    TXTextControl1.FindReplace FINDREPL_REPLACE
End Sub
```

The find options of the dialog boxes include the main text, footnotes, text frames and headers and footers:

![The built-in Replace dialog box of TX Text Control ActiveX 34.0 with Find what, Replace with, the find options and the Find Next, Replace, Replace All and Cancel buttons.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/replace-find-options.962b48bb.webp)

To search in code without a dialog box, use the [Find](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/find-method/llms-full.txt) method, which [Selections, Clipboard and Undo](https://docs.textcontrol.com/tx-text-control-activex/document-editor/editing/#search-the-text) describes.

### Add Paragraph Frames

With TX Text Control, you can add lines and frames to a paragraph or a range of paragraphs, for example a line above a caption. Users set them on the **Frame and Page Breaks** tab of the built-in **Paragraph** dialog box, which **Format** > **Paragraph...** opens with [ParagraphDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/paragraphdialog-method/llms-full.txt). `TXTextControl1.ParagraphDialog 1` opens the dialog box directly on this tab.

![The Frame and Page Breaks tab of the built-in Paragraph dialog box of TXTextControl with the frame lines, line width and color, background color and pagination options.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/paragraph-dialog-frames.4dc0ad1f.webp)

In code, these properties set the frame of the selected paragraphs:

- [FrameStyle](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/framestyle-property/llms-full.txt)
- [FrameLineWidth](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/framelinewidth-property/llms-full.txt)
- [FrameDistance](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/framedistance-property/llms-full.txt)

[Character and Paragraph Formatting](https://docs.textcontrol.com/tx-text-control-activex/document-editor/formatting/#add-frames-and-background-colors) shows them in use.

### Choose Text and Background Colors

TXWords has no color commands of its own. The user chooses the text color and the text background color on the **Font and Color** tab of the **Font** dialog box, which **Format** > **Character...** opens with [FontDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fontdialog-method/llms-full.txt), and the background color of paragraphs on the **Frame and Page Breaks** tab of the **Paragraph** dialog box. In code, [ForeColor](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/forecolor-property/llms-full.txt) sets the text color, [TextBkColor](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/textbkcolor-property/llms-full.txt) the background color of the selected text and [FrameColor](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/framecolor-property/llms-full.txt) the background color of the selected paragraphs.

![The Font and Color tab of the built-in Font dialog box of TXTextControl with the font, size, text and background colors, attributes and underlining.](https://docs.textcontrol.com/assets/img/tx-text-control-activex/font-dialog-font-color.44aa8fd2.webp)

### Key Members

| Member | Description |
|---|---|
| [SectionFormatDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/sectionformatdialog-method/llms-full.txt) | Opens the **Page Setup** dialog box for page size, margins, headers and footers, columns and page borders. |
| [PrintDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/printdialog-method/llms-full.txt) | Opens the system print dialog box and prints the document. |
| [FindReplace](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/findreplace-method/llms-full.txt) | Opens the dialog box for searching (1) or for searching and replacing (2). |
| [ParagraphDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/paragraphdialog-method/llms-full.txt) | Opens the **Paragraph** dialog box, whose second tab sets paragraph frames. |
| [FontDialog](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/fontdialog-method/llms-full.txt) | Opens the **Font** dialog box, which also sets the text colors. |
| [FrameStyle](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/framestyle-property/llms-full.txt), [FrameLineWidth](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/framelinewidth-property/llms-full.txt), [FrameDistance](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/framedistance-property/llms-full.txt) | Set the frame lines, their width and the distance to the text of the selected paragraphs. |
| [ForeColor](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/forecolor-property/llms-full.txt), [TextBkColor](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/textbkcolor-property/llms-full.txt) | Set the color and the background color of the selected text. |

### Next Steps

- [Built-in Dialog Boxes](https://docs.textcontrol.com/tx-text-control-activex/document-editor/dialog-boxes/llms-full.txt): every dialog box that TXWords opens, with its menu item.
- [Setting the DPI Awareness](https://docs.textcontrol.com/tx-text-control-activex/integration/dpi-scaling/llms-full.txt): embedding a manifest that makes TXWords DPI aware.
- [Printing](https://docs.textcontrol.com/tx-text-control-activex/document-editor/printing/llms-full.txt): printing pages, page ranges and paper bins.
- [Working with Files](https://docs.textcontrol.com/tx-text-control-activex/document-editor/load-save/llms-full.txt): the file formats TXWords loads and saves.
- [Creating a Simple Word Processor](https://docs.textcontrol.com/tx-text-control-activex/getting-started/first-application/llms-full.txt): the first tutorial, which builds a smaller word processor step by step.

---

## Nearby

- **Previous:** [Document Properties](https://docs.textcontrol.com/tx-text-control-activex/document-editor/properties/llms-full.txt)
- **Next:** [Tables](https://docs.textcontrol.com/tx-text-control-activex/document-editor/tables/llms-full.txt)
