When you work in a visual development environment, your time is spent in two different parts of the application: the visual designer and the code editor. The designer lets you work with components on a visual level (such as when you place a button on a form), or on a non-visual level (such as when you place a DataSet component on a data module). You can see a form and a data module in the action in Figure 1.1. In both cases, the designer allows you to select the components you need and set initial values for their properties.
Figure 1.1 A form and a data module in Delphi 7 IDE
The code editor is where you write code. The most obvious way to write code in a visual environment is to include reactions to events, initiated by actions performed by the user of the program, such as clicking a button or selecting an option in a list box. You can use the same approach to handle internal events, such as those involving database changes or notifications from the operating system.
When programmers become familiar with Delphi, they often start by writing mostly event-handling code, then move on to writing their own classes and components, and finally spend most of their time in the editor. Because this book covers far more than visual programming, trying to help you grasp the entire power of Delphi, as the text deepens, you will see more code and fewer forms.
An important change first appeared in Delphi 6. The IDE now allows you to work on two different visual class libraries: VCL (Visual Component Library, Visual Component Library) and CLX (Component Library for Cross-Platform). When you create a new project, you can simply choose which one of the two class libraries you want to use, and start like this: Create a typical VCL-based Windows program through the File ® New ® application command; ® New ® CLX Application command creates a new CLX-based portable application.
Comment | CLX is a cross-platform library for Delphi that allows you to recompile your code with Kylix to run under Linux. You can read more about CLX and VCL in Chapter 5, "Visual Controls." Using CLX in Delphi 7 is more interesting because the Delphi language version of Kylix ships with the Windows product. |
When you create a new project or open an existing one, the component palette is arranged to display only the controls relevant to the current library (although most controls are shared). When you operate a non-visual designer (such as a data module), the component palette label of the visual component is hidden and invisible.
Programmers can customize the IDE in various ways—typically, opening many windows, arranging them, and docking them to each other. However, you often need to open one set of window settings when designing and a different set of window settings when debugging. Likewise, you might need one layout when working with a form, and a completely different layout when writing components or low-level code using just the editor. Reorganizing the IDE for each such need is a very tedious task.
For this reason, Delphi allows you to save a specific IDE window (called the desktop desktop , or Global Desktop, to distinguish it from the project desktop PProject Desktop) under a name and easily restore it. You can also save one of your default debugging settings, which will be automatically restored when you start debugging the program. All these features are available from the Desktops toolbar. You can also use the View ® Desktops menu to manipulate desktop settings.
Desktop setting information is saved in DST files (stored in Delphi's bin directory), which are disguised INI files. Saved settings include the main window, Project Manager, Alignment Palette, Object Inspector (including its property category settings), editor windows (the status of Code Explorer and Message View), and many other locations, plus various windows docked status.
Here's a small excerpt from a DST file, it should be easy to read:
[Main Window]
Create=1
Visible=1
State=0
Left=0
Top=0
Width=1024
Height=105
ClientWidth=1016
ClientHeight=78
[ProjectManager]
Create=1
Visible=0
State=0
...
Dockable=1
[AlignmentPalette]
Create=1
Visible=0
...
Desktop settings override project settings, which are saved in a similarly structured DSK file. Desktop settings help remove the headaches that occur when you move a project between machines (or between developers) and have to rearrange windows to your liking. Delphi separates each user's global desktop settings and each project's desktop settings to better support team development.
Skill | If you open Delphi and can't see forms or other windows, I suggest you try checking (or deleting) the desktop settings (from the Delphi bin directory). If you open a project accepted by a different user and cannot see some windows or don't like the desktop layout, load your global desktop settings again or delete the project DSK file. |