This message contains graphics. If you do not see the graphics: Graphic Version.
Creating a Simple Word Processor in Delphi .NET

This article shows you how to integrate TX Text Control .NET for Windows Forms into Delphi 8.0 .NET and above. It describes how to create a simple word processing application from scratch.

Creating the Project

After installing TX Text Control using the setup program, start Delphi .NET and create a new project. Select a Delphi for .NET Windows Forms application project.

Then use the Component / Installed .NET components dialog to add TX Text Control .NET for Windows Forms to your tool palette. In the .NET Components tab, look for the four TX Text Control .NET for Windows Forms components. If you sort the list by Namespace, you will see the 4 components:

  • TextControl
  • ButtonBar
  • RulerBar
  • StatusBar

Check them and click OK.

After closing the dialog, you will see the four TX Text Control .NET for Windows Forms icons in the Tool Palette.

Creating the Controls

In this step, you put these controls on a form and connect them. Click on the ButtonBar icon and draw it on to the form. Do the same for the other three components. The form should now look like this:

Now set the Dock property to Top for the Button Bar and the Ruler Bar. TX Text Control should be set to Fill and the Status Bar to Bottom.

Connecting the Toolbars

At this stage, while you can type into TX Text Control, the button bar and the ruler bar cannot be used. They must be connected to TX Text Control in the form's Load event.

procedure TWinForm.TWinForm_Load(sender: System.Object; e: System.EventArgs); begin TextControl1.ButtonBar := ButtonBar1; TextControl1.RulerBar := RulerBar1; TextControl1.StatusBar := StatusBar1; end;

Now start the application by pressing F9 and ensure that the toolbars are connected to TX Text Control.

Adding Menus

Now, we will add some menus to call the built-in dialog boxes of TX Text Control .NET for Windows Forms.

Drag a MainMenu control on your form and create a Format menu with the items Character... and Paragraph.... Label the items mnuFomat_Character and mnuFormat_Paragraph. Add the following code to the Click procedures of the menu items:

procedure TWinForm.mnuFormat_Paragraph_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.ParagraphFormatDialog; end; procedure TWinForm.mnuFormat_Character_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.FontDialog; end;

Now, create an Edit menu with the items Cut, Copy and Paste. The code for these items is:

procedure TWinForm.mnuEdit_Paste_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Paste; end; procedure TWinForm.mnuEdit_Copy_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Copy; end; procedure TWinForm.MenuItem3_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Cut; end;

After adding these menu items, you will be able to cut, copy or paste text from other applications via the clipboard.

The last menu should implement a simple file menu. Create a File menu with the items Open File... and Save File As... and use the following code:

procedure TWinForm.mnuFile_Save_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Save; end; procedure TWinForm.mnuFile_Open_Click(sender: System.Object; e: System.EventArgs); begin TextControl1.Load; end;

The Load and Save methods are called without any parameters, so that they automatically open a dialog box for the end user to select the filename and the format. After clicking Open in the dialog, TX Text Control will load the selected file properly.

The minimum requirements for this sample application are TX Text Control .NET for Windows Forms trial version and Delphi 8.0 for Microsoft .NET Framework.

Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2020 Text Control GmbH. All Rights Reserved.