Creating a text editor using delphi

Páginas: 27 (6554 palabras) Publicado: 5 de abril de 2011
Tutorial: Creating a Text Editor using Delphi

Borland®

Kylix 3


Delphi™ and C++ for Linux®
Borland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249 www.borland.com

COPYRIGHT © 2001–2002 Borland Software Corporation. All rights reserved. All Borland brand and product names are trademarks or registered trademarks of Borland Software Corporation in the UnitedStates and other countries. All other marks are the property of their respective owners. K3–Delphi_TE–0702

Contents
Creating a text editor using the Delphi IDE
Starting a new application . . . . . Setting property values . . . . . . Adding components to the form . Adding support for a menu and a toolbar . . . . . . . . . . . Adding actions to the action list Adding standard actions to theaction list . . . . Adding images to the image list Adding a menu . . . . . . . . . . . Clearing the text area . . . . . . . . Adding a toolbar . . . . . . . . . . . . . . . . . . 1 . . . . . . . . 3 . . . . . . . . 3 . . . . . . . . 6 . . . . . . . . 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 11 13 15 16 Writing event handlers . . . . . . Writing the New command eventhandler . . . . . . . . . Writing the Open command event handler . . . . . . . . . Writing the Save command event handler . . . . . . . . . Writing the Save As command event handler . . . . . . . . . Writing the Exit command event handler . . . . . . . . . Creating an About box . . . . . . Completing your application . . . . . . . . . . . 17 . . . . . . . . 17 . . . . . . . . 19 . . . . . . . . 21. . . . . . . . 22 . . . . . . . . 23 . . . . . . . . 24 . . . . . . . . 26

Index

iii

iv

Chapter0

Creating a text editor using the Delphi IDE

This tutorial guides you through the creation of a text editor complete with menus, a toolbar, and a status bar. You will use the Delphi IDE to create the text editor. This tutorial assumes you are familiar with Linux and have read theintroduction to Kylix programming and the IDE in the Quick Start.
Note

This tutorial is for all editions of Kylix.

Starting a new application
Before beginning a new application, create a directory to hold the source files:

1 Create a directory called TextEditor in your home directory. 2 Begin a new project by choosing File|New Application or use the default project that is already openwhen you started the Delphi IDE.
Each application is represented by a project. When you start Kylix, it creates a blank project by default, and automatically creates the following files: • Project1.dpr: a source-code file associated with the project. This is called a project file. • Unit1.pas: a source-code file associated with the main project form. This is called a unit file. • Unit1.xfm: aresource file that stores information about the main project form. This is called a form file. Each form has its own unit (Unit1.pas) and form (Unit1.xfm) files. If you create a second form, a second unit (Unit2.pas) and form (Unit2.xfm) file are automatically created.

Creating a text editor using the Delphi IDE

1

Starting a new application

3 Choose File|Save All to save your files todisk. When the Save dialog box appears:
• Navigate to your TextEditor folder. • Save Unit1 using the default name Unit1.pas. • Save the project using the name TextEditor.dpr. (The executable will be named the same as the project name without an extension.) Later, you can resave your work by choosing File|Save All. When you save your project, Kylix creates additional files in your project directory.Do not delete these files. When you open a new project, Kylix displays the project’s main form, named Form1 by default. You’ll create the user interface and other parts of your application by placing components on this form.

The default form has Maximize and Minimize buttons, a Close button, and a Control menu. If you run the form now by pressing F9, you’ll see that these buttons all work. To...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Editores de texto
  • Editores de texto
  • Editores de texto
  • Editor de texto
  • Editor de texto
  • Editores de texto
  • Editores de texto
  • Editores de texto

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS