
- •Using the Object Repository: Overview
- •Sharing items within a project
- •-Adding items to the Object Repository
- •Sharing objects in a team environment
- •Using an Object Repository item in a project
- •Copying an item
- •Inheriting an item
- •Using project templates
- •Modifying shared items
- •Specifying a default project, new form, and main form
- •Developing the application user interface: Overview
- •Controlling application behavior
- •Working at the application level
- •Using the main form
- •Hiding the main form
- •Adding forms
- •Managing layout
- •Using forms
- •Creating modeless forms such as windows
- •Creating a form instance using a local variable
- •Passing additional arguments to forms
- •Retrieving data from forms
- •Creating and using component templates
- •Working with frames
- •Merging menus
- •Assigning a speed button's glyph
- •Common controls and xp themes
- •1. Answer the questions:
- •8.1 Text viewing controls
- •8.2 Specialized input controls
- •8.3 Track bars
- •Cool bars (vcl only)
- •Combo boxes
- •Tree views
- •Date-time pickers and month calendars
- •Scroll boxes
- •Tab controls
Creating modeless forms such as windows
You must guarantee that reference variables for modeless forms exist for as long as the form is in use. This means that these variables should have global scope. In most cases, you use the global reference variable that was created when you made the form (the variable name that matches the name property of the form). If your application requires additional instances of the form, declare separate global variables for each instance.
Creating a form instance using a local variable
A safer way to create a unique instance of a modal form is to use a local variable in the event handler as a reference to a new instance. If a local variable is used, it does not matter whether ResultsForm is auto-created or not. The code in the event handler makes no reference to the global form variable.
Passing additional arguments to forms
Typically, you create forms for your application from within the IDE. When created this way, the forms have a constructor that takes one argument, Owner, which is the owner of the form being created. (The owner is the calling application object or form object.) Owner can be nil.
To pass additional arguments to a form, create a separate constructor and instantiate the form using this new constructor.
Retrieving data from forms
Most real-world applications consist of several forms. Often, information needs to be passed between these forms. Information can be passed to a form by means of parameters to the receiving form's constructor, or by assigning values to the form's properties. The way you get information from a form depends on whether the form is modal or modeless.
Creating and using component templates
You can create templates that are made up of one or more components. After arranging components on a form, setting their properties, and writing code for them, save them as a component template. Later, by selecting the template from the Component palette, you can place the preconfigured components on a form in a single step; all associated properties and event-handling code are added to your project at the same time.
Working with frames
A frame (TFrame), like a form, is a container for other components. It uses the same ownership mechanism as forms for automatic instantiation and destruction of the components on it, and the same parent-child relationships for synchronization of component properties.
In some ways, however, a frame is more like a customized component than a form. Frames can be saved on the Component palette for easy reuse, and they can be nested within forms, other frames, or other container objects. After a frame is created and saved, it continues to function as a unit and to inherit changes from the components (including other frames) it contains. When a frame is embedded in another frame or form, it continues to inherit changes made to the frame from which it derives.
Creating frames
To create an empty frame, choose File|New|Frame, or choose File|New|Other and double-click Frame. You can then drop components (including other frames) onto your new frame.
Using open dialog boxes
One of the commonly used dialog box components is TOpenDialog. This component is usually invoked by a New or Open menu item under the File option on the
main menu bar of a form. The dialog box contains controls that let you select groups of files using a wildcard character and navigate through directories.
Setting up action bands
Because actions do not maintain any "layout" (either appearance or positional) information, Delphi provides action bands which are capable of storing this data. Action bands provide a mechanism that allows you to specify layout information and a set of controls. You can render actions as UI elements such as toolbars and menus.
What happens when an action tires
When an event fires, a series of events intended primarily for generic actions occurs. Then if the event doesn't handle the action, another sequence of events occurs.
Updating actions
When the application is idle, the On Update event occurs for every action that is linked to a control or menu item that is showing. This provides an opportunity for applications to execute centralized code for enabling and disabling, checking and un- checking, and so on.
Creating and managing menus
Menus provide an easy way for your users to execute logically grouped commands. The Menu Designer enables you to easily add a menu either predesigned or custom tailored to your form. You add a menu component to the form, open the Menu Designer, and type menu items directly into the Menu Designer window. You can add or delete menu items, or drag and drop them to rearrange them during design time.