Basic Delphi - A Text Editor

The Edit Window

Drag a memo component onto the form and roughly set the size. In the Object Inspector, select the Memo's Align property and set it to alClient - this will make the Memo occupy all the available space on the Form.

Change the Name to Memo and set the Scrollbars property to ssVertical.

OK, visually, the editor is almost complete. For the finishing touches, we can give the Form's Title Bar a better caption than Form1 and we can define its position on the screen when it first starts up.

We need to select the Form in the Object Inspector but, because we can no longer actually see any of the Form's surface (the Memo occupies the entire surface), we can't simply click on the Form to show it in the Object Inspector.

We can make the Form the active object in the Object Inspector either by clicking it in the Object TreeView window or by selecting it in the DropDown List at the top of the Object Inspector.

Change the Form's Caption to Text Editor.

Scroll down the Object Inspector to find the Form's Position property and change it to poDesktopCenter.

We're ready to run our project to see what it looks like. Hit key F9 and our project will run. Note that we can already type in and edit the text window and the File Menu items are displayed - although they don't actually do anything yet when we click them. However, we can resize the form and the System Menu and Minimize, Restore and Close buttons work. We can right-click the Memo and a Popup menu appears -- all without writing a single line of code!

Starting & Stopping Our Program

There are at least three different ways to run a program in the Delphi Environment. We can hit the F9 key, hit the green triangle on the Main Window's ToolBar or we can select Run from the Menu Bar.

To stop the program, we can use the program's Close button or select Program Reset from Delphi's Run Menu Bar item.

There is one more way we can run our Editor. If you look in the folder where you saved the project's files, you will find our program has already been converted to an executable - TextEditor.exe -- It's already become a stand-alone program in its own right! And Delphi executables truely are stand-alone, requiring absolutely no runtime support files.

In the next part, we'll add the code to make our Menu Bar items spring into life!

Previous | Next