Сделай Сам Свою Работу на 5

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 vari­able 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 in­stantiate 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 Com­ponent 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 compo­nents (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 de­rives.



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 com­ponent 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. Ac­tion 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 oc­curs.

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 ap­plications 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 com­mands. 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.

Merging menus

For MDI applications, such as the text editor sample application, and for OLE client applications, your application's main menu needs to be able to receive menu items either from another form or from the OLE server object. This is often called merging menus. Note that OLE technology is limited to Windows applications only and is not available for use in cross-platform programming.

Assigning a speed button's glyph

Each speed button needs a graphic image called a glyph to indicate to the user what the button does. If you supply the speed button only one image, the button ma­nipulates that image to indicate whether the button is pressed, unpressed, selected, or disabled. You can also supply separate, specific images for each state if you prefer.

Common controls and XP themes

Microsoft has forked Windows common controls into two separate versions. Version 5 is available on all Windows versions from Windows 95 or later; it displays controls using a "3D chiseled" look. Version 6 became available with Windows XP. Under version 6, controls are rendered by a theme engine which matches the current Windows XP theme. If the user changes the theme, version 6 common controls will match the new theme automatically. You don't need to recompile the application.

Tasks

1. Answer the questions:

1 What does the Object Repository provide?

2 Name the steps for adding an item to the Object Repository.'

7.2. Tell about copying and inheriting an item.

1 How can you create a new project from a template?

2 What must you do to specify a default project?

3 Tell about the classes that form the backbone of all applications.

4 What can you say about using and hiding the main form?

5 How can you avoid "Circular reference" error?

6 What are modal and modeless forms?

j) Name the steps to pass additional arguments to a form, k) Tell about the difference between a frame and a component. I) What do actions bands provide? m) Give the definition of glyph.

2. Translate into English:а) объектный архив; общие элементы; модули данных; групповое окружение; совместно используемый архив; существующий элемент; точная копия; отраженный в копии; получить новый класс; предварительно сконструированные проекты; шаблон первичного проекта; нетронутый изменениями; изменение общедоступных элементов; распространять изменения; текущий проект; проект по умолчанию; пустая форма; интерфейс пользователя приложения;



б) основа всех приложений; сохранять формы и модули данных; поддержание системно-специфической информации; разрешение экрана; глобальная переменная; фоновый режим программы; прятание основной программы; порядок создания формы; предотвращать появление основной формы; связывающие формы.ошибка. циклической зависимости; во время выполнения программы; модальные и немодальные формы; передавать дополнительные параметры форме; восстановление данных из форм; разме­щение компонентов на форме; установка свойств; механизм монопольного использования; для синхронизма свойств компонентов.вложены внутри форм; структура внедрена; компонент обычно вызывается; групповой символ; передвигаться через директории; поддерживать "размещение"; событие "стреляет"; неактивное приложение; установка полос действия; приспособленный к форме; меню объединения; назначение глифа; кнопка быстрого действия; графический образ; распространять общие средства управления.

Text viewing controls

In CLX applications only, the text viewing controls display text but are read­only.

Use this component: When you want users to do this: TTextBrowser Display a text file or simple HTML page that users can scroll through.

TTextViewer Display a text file or simple HTML page. Users can scroll through the page or click links to view other pages and images.

TLCDNumber Display numeric information in a digital display form.

 








Не нашли, что искали? Воспользуйтесь поиском по сайту:



©2015 - 2024 stydopedia.ru Все материалы защищены законодательством РФ.