• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

delphi常用函数(类)七

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

1、 TApplication

TApplication is the type used for a GUI windowed application.

Unit

QForms

Description

TApplication encapsulates a windowed application. The methods and properties introduced in TApplication reflect the fundamentals established in the operating system to create, run, sustain, and destroy an application. TApplication thereby simplifies the interface between the developer and the windowing environment. For this purpose TApplication encapsulates behavior for

System-generated event processing.

Context-sensitive online help.

Menu accelerator and key processing.

Exception handling.

Each GUI application automatically declares an Application variable as the instance of the application. This variable is of type TApplication.

TApplication does not appear on the Component palette, nor is it available in the form designer to visually manipulate; so it has no published properties. Nevertheless, some of its public properties can be set or modified at design time in the Forms and Application pages of the Project|Options dialog box. In addition, TApplication introduces a number of events to which you may want to respond. To write an event handler for one of these events, add a method of the appropriate type to the main form in your application, and then at runtime, assign that method as the handler for the event.

Note: For application-wide properties and methods that affect the display, see TScreen.

2、 Application variable

Represents application-level information.

Unit

QForms

Category

application-level information

var Application: TApplication;

Description

By default, when a new project is created, Kylix constructs an application object and assigns it to the Application variable in the QForms unit. Application has several properties that can be used to get information about an application while it runs.

Example:

This code displays the name of your project in an edit box:

procedure TForm1.Button1Click(Sender: TObject);

begin

Edit1.Text := Application.Title;

end;

3、 Understanding datasets

The fundamental unit for accessing data is the dataset family of objects. Your application uses datasets for all database access. A dataset object represents a set of records from a database organized into a logical table. These records may be the records from a single database table, or they may represent the results of executing a query or stored procedure.

All dataset objects that you use in your database applications descend from TDataSet, and they inherit data fields, properties, events, and methods from this class. TDataSet is a virtualized dataset, meaning that many of its properties and methods are virtual or abstract. A virtual method is a function or procedure declaration where the implementation of that method can be (and usually is) overridden in descendant objects. An abstract method is a function or procedure declaration without an actual implementation. The declaration is a prototype that describes the method (and its parameters and return type, if any) that must be implemented in all descendant dataset objects, but that might be implemented differently by each of them.

Because TDataSet contains abstract methods, you cannot use it directly in an application without generating a runtime error. Instead, you either create instances of the built-in TDataSet descendants and use them in your application, or you derive your own dataset object from TDataSet or its descendants and write implementations for all its abstract methods.

TDataSet defines much that is common to all dataset objects. For example, TDataSet defines the basic structure of all datasets: an array of TField components that correspond to actual columns in one or more database tables, lookup fields provided by your application, or calculated fields provided by your application. For information about TField components, see "Working with field components”.

4、 TWinControl

TWinControl is the base class for all controls that are wrappers for Microsoft Windows screen objectss.

Unit

Controls

Description

TWinControl provides the common functionality for all controls that act as wrappers for Microsoft Windows screen objects (“windows”) Controls that are wrap underlying windows have the following features:

The control can incorporate the functionality of an underlying window. For example, if the underlying screen object is a text editor, the control can incoporate the editor ability to manage and display a text buffer.

The control can receive user input focus. The focused control can handle keyboard input events. Some controls change their appearance when they have the focus. For example, button controls typically indicate the focus by drawing a rectangle around the caption.

The control can serve as a container for other controls, referred to as child controls. This relationship is signified by the child's Parent property. Container controls provide important services to their children, including display services for controls that do not implement their own canvases. Examples of container controls include forms, panels, and toolbars.

Controls based on TWinControl can display standard screen objects provided by Microsoft Windows, or customized screen objects developed by the VCL programmer.

Descendants of TWinControl include abstract base classes that support most kinds of user interface objects. The most significant descendant is TCustomControl, which provides code to implement a canvas and handle paint messages. Other important abstract descendants include TScrollingWinControl, TButtonControl, TCustomComboBox, TCustomEdit, and TCustomListBox. When defining new control classes, consider these descendants before deriving directly from TWinControl.

Every TWinControl object has a Handle property which returns the window handle for the underlying Microsoft Windows screen object. Use the Handle property to bypass the VCL API and directly access the underlying window.

TWinControl.Create

Creates an instance of TWinControl.

constructor Create(AOwner: TComponent); override;

Description

Call Create to construct and initialize a new control and insert the newly-constructed control into its owner, as specified by the AOwner parameter. Create inserts the control in the owner by calling the owner's InsertComponent method.

Most controls override Create to initialize their unique properties. Objects that override the Create method must always call the inherited Create method first, and then proceed with the component-specific initialization. Specify the override directive when overriding the Create method.

If a component's Create method allocates resources or memory, override the Destroy method to free those resources.


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap