Chapter 1: Getting Started with Delphi


This chapter serves primarily as an introduction to the Delphi IDE and the basics of creating a console application. This chapter doesn't provide you with a detailed overview of all IDE elements but rather describes only those elements that are needed to get you on the right track. Other IDE elements are described later in the book.

The Delphi IDE

The Delphi IDE (integrated development environment) appears when you start Delphi. The Delphi IDE is made up of a number of tools that are used to design, build, and test applications. Figure 1-1 shows the Delphi IDE.

image from book
Figure 1-1: The Delphi IDE

Elements of the Delphi IDE

Even though Delphi contains a vast number of tools for developing applications, only a small number of these are shown at startup. The most significant tools of the Delphi IDE are:

  • Tool Palette

  • Designer Surface

  • Object Inspector

  • Structure View

  • Code Editor

  • Project Manager

  • Main menu and the toolbars

Tool Palette

The Tool Palette (previously known as the Component Palette) is a window in the bottom-right corner of the IDE. The Tool Palette is an enhanced version of the Component Palette. It displays a collection of components or files and projects you can create in Delphi. If you are new to programming, it will suffice for now to know that components are the basic building blocks of Windows-based applications.

To see the default collection of components used to build Windows applications, we have to create a new Windows application project. To create a new project, select File ® New ® VCL Forms Application - Delphi for Win32 or double-click the VCL Forms Application item in the Delphi Projects category on the Tool Palette window.

image from book Figure 1-2: The Tool Palette

Designer Surface

The Designer Surface (previously known as the Form Designer) is the central portion of the Delphi IDE. The Designer Surface (see Figure 1-3) is actually the main window of the new application, but at design time, it is used as a drawing canvas to create the application user interface.

image from book
Figure 1-3: The Designer Surface

To build a user interface in Delphi, you use the Designer Surface in unison with the Tool Palette and the Object Inspector. Using these three tools, the process of creating a user interface is reduced to three simple steps:

  1. Select the component on the Tool Palette.

  2. Drop the selected component onto the Designer Surface.

  3. Customize the component with the Object Inspector.

The dots displayed on the Designer Surface are the Designer Grid. The Designer Grid is only visible at design time and is a very useful tool for helping maintain a consistent spacing between components on the form. If you don't need the Designer Grid, you can hide it or disable it in the Options dialog box. To do this, select Tools ® Options, expand the Environment Options and the Delphi Options nodes, and select VCL Designer. Finally, uncheck the Display grid and Snap to grid options.

Object Inspector

The Object Inspector, just like the Designer Surface, is an invaluable tool in the Delphi repertoire. The Object Inspector is used to display and modify properties of the selected form or the selected component(s) on the form. Component properties are various values that define a component. Many of the properties displayed in the Object Inspector define how the component looks on the screen.

When a new project is created, the Object Inspector automatically displays properties of the main form. In previous versions of Delphi, the Object Inspector displayed component properties alphabetically, but in versions 8.0 and later, the default style has been changed and the properties are displayed in categories. To display properties alphabetically, right-click the Object Inspector and select Arrange ® By Name on the pop-up menu.

image from book Figure 1-4: The Object Inspector

The Object Inspector consists of two parts. The drop-down list at the top is known as the instance list. It lists all components on the selected form (including the form itself) and shows the currently selected component. Below the instance list are two tabs. The Properties tab displays the properties of the selected component, and the Events tab displays the events to which the component can respond. An event is a section of code that gets executed when something happens in your application, and that something is usually a mouse click or a keypress.

Structure View

The Structure View displays the hierarchy of components on the form and enables us to change hierarchy relations between components using simple drag and drop techniques. The Structure View is an especially valuable tool in larger applications. Figure 1-5 shows the hierarchical representation of a form with a large number of components.

image from book Figure 1-5: The Structure View

The Structure View has replaced two tools from previous Delphi versions: the Object TreeView and the Code Explorer. While you're designing the user interface, the Structure View displays the component hierarchy (like the Object TreeView in previous versions). When you switch to the Code Editor, the Structure View shows the hierarchy of various source code segments (like the Code Explorer in previous versions).

Code Editor

The Code Editor is a very sophisticated tool for entering the code for the application. To display the Code Editor, click on the Code tab in the status bar of the Delphi IDE.

image from book
Figure 1-6: The Code Editor

Tip 

The fastest way to display the Code Editor is to press the F12 key on the keyboard. The F12 key is used to switch between the Designer Surface and the Code Editor.

After a better look at the Code Editor, we can see two things: The editor supports syntax highlighting and we can see that because there is already a decent amount of code in the editor. The first is a really good thing, and the second only seems bad if you're a beginning programmer.

The Code Editor in Delphi 2006 is an absolute beauty. Besides syntax highlighting, it has the extremely useful Sync Edit ability, which enables you to simultaneously edit duplicate identifiers in the selected portion of code.

Project Manager

The Project Manager is a window in the upper-right corner of the Delphi IDE that displays the files that make up the current project. The Project Manager also enables us to perform various project-related tasks such as adding/ removing files and compiling. This tool will be really useful when we start building our own components and packages.

Main Menu and Toolbars

The main menu is your door into the Delphi world. As in all other Windows applications, the main menu contains all options available in the application. The options that you are likely to use often can also be found on the toolbars. Toolbars are used to provide a faster way to access often-used options, and they never contain an option that cannot be found on the main menu.

Toolbars can be easily configured to better suit your needs. You can customize a toolbar by using the Customize dialog box.

To display the Customize dialog box, right-click on a toolbar and then select Customize from the pop-up menu.

image from book
Figure 1-7: Customizing toolbars



Inside Delphi 2006
Inside Delphi 2006 (Wordware Delphi Developers Library)
ISBN: 1598220039
EAN: 2147483647
Year: 2004
Pages: 212
Authors: Ivan Hladni

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net