• VCL组件的属性和方法详解


    http://www.delphifans.com/infoview/Article_663.html

    一、TApplication
    继承关系:
    TObject → TPersistent → TComponent

    TApplication组件的属性:
    Active
    AllowTesting
    DialogHandle
    ExeName
    Handle
    HelpFile
    Hint
    HintColor
    HintHidePause
    HintPause
    HintShortPause
    Icon
    MainForm
    ShowHint
    ShowMainForm
    Terminated
    Title
    UpdateFormatSettings
    UpdateMetricSettings

    从TCompnent继承来的:
    ComObject
    ComponentCount
    ComponentIndex
    Components
    ComponentState
    ComponentStyle
    Designlnfo
    Name
    Owner
    Tag
    VCLComObject

    TApplication组件的方法:
    BringToFront
    CancelHint
    ControlDestroyed
    Create
    CreateFom
    CreateHandle
    Destroy
    HandleException
    HandleMessage
    HelpCommand
    HelpContext
    HelpJump
    HideHint
    HintMouseMessage
    HookMainWindow
    lnitialize
    MessageBox
    Minimize
    NormalizeTopMosts
    NormalizeAllTopMosts
    ProcessMessages
    Restore
    RestoreTopMosts
    Run
    ShowException
    Terminate
    UnhookMainWindow

    从TComponent继承来的:
    DestroyComponents
    Destroying
    FindComponent
    FreeNotification
    FreeOnRelease
    GetParentComponent
    HasParent
    InsertComponent
    RemoveComponent
    SafeCallException

    从TPersistent继承来的:
    Assign
    GetNamePath

    TObject继承来的:
    ClassInfo
    ClassNarne
    ClassNameIs
    ClassParent
    ClassType
    CleanupInstance
    DefaultHandler
    Dispatch
    FieldAddress
    Free
    Freelnstance
    GetInterface
    GetInterfaceEntry
    GetInterfaceTable
    InheritsForm
    InitInstance
    InstanceSize
    MethodAddress
    MethodName
    NewInstance

    TApplication组件的事件:
    OnActivate
    OnDeactivate
    OnException
    OnHelp
    OnHint
    OnIdle
    OnMessage
    OnMinimize
    OnRestore
    OnShowHint

    Active属性
    对应对象:TApplication
    声明:property Active: Boolean;
    功能:Active属性是用来声明应用程序是否被激活。Active属性是在运行时有效,它是只读类型的。当应用程序处于激活状态并且具有焦点时,它将返回真,否则将返回假。

    BringToFront方法
    对应对象:TApplication
    声明:procedure BringToFront;
    功能:BringToFront方法用于将用户的应用程序的主窗体窗口放置到Windows Desktop上的其他窗口的前面。Windows Desktop有一个Z轴的次序,确定一个窗口相对于其他窗口的逻辑位置(上或下)。这个Z轴次序允许窗口以叠加的形式出现,同时确定当前的带有焦点的窗口。BringToFront使用户的应用程序的主窗体的窗口放置在Z轴次序的上部,这样将使它拥有焦点并且处于被激活的状态,使其出现在Desktop的所有窗口之上。

    CreateFom方法
    对应对象:TApp1ication
    声明:procedure CreateForm(InstanceClass: TComponentClass; var Reference);
    功能:CreateForm方法用来创建一个新的窗体。InstanceClass是要被创建的窗体的类型。Reference是赋予窗体的变量。Application对象拥有新创建的窗体。在项目源代码中至少应调用一次CreateForm,且该应用程序的每一个窗体都将被调用,这些调用是由Delphi自动地调用,不需要用户人工调用。

    ExeName属性
    对应对象:TApplication
    声明;property ExeName: string;
    功能:ExeName包含了应用程序可执行文件的目录和文件名。ExeName属性在运行时有效,并且为只读型的。它包含有应用程序的可执行文件名。

    Handle属性
    对应对象:TApplication
    声明:propeny Handle: HWND;
    功能:包含有应用程序窗口的句柄。Handle属性在处理一个需要窗口句柄的API的调用时使用的。通常用户不需要自己去访问Application.Handle属性。注意这里指的是不可视的应用程序窗口的句柄并不是主体窗口的句柄。要获得主体窗口的句柄应使用TForm对象的Handle属性。

    HeIpCommand方法
    对应对象:TApplication
    声明:fuction HelpCommand(Command:Integer;Data:Longint):Boolean;
    功能:HelpCommand允许用户访问Windows Help API中的任何命令。 Command是需要被调用的Windows Help API命令。Data是需要被传送给Help命令的数据。HelpCommand方法调用了Windows Help的文件WINHELP.EXE,并且将它传送给由Command参数指定的命令及由Data参数指定的数据,被发送的命令指定了请求帮助的类型,而被发送的数据则依请求的命令而确定。以下例出了可以被传送给HelpCommand的部分命令和数据值。

    命 令 值 /数 据 值 / 意 义

    HELP_COMMAND / 包含将要执行的Help宏命令或一毓由分号分隔的Help宏命令的字符串地址 / 执行Help宏命令或宏命令集。

    HELP_CONTENTS / 0 / 此项是为与4.0版本之前的帮助引擎相兼容而提供的命令。对应32位应用程序应使用HELP_FINDER命令。

    HELP_CONTEXT / 主题的上下文标识符 / 显示由Data值标识的标题。

    HELP_CONTEXTPOPUP / 主题的上下文标识符 / 创建一个显示了Data值指定的主题的弹出式窗口。

    HELP_FINDER / 0 / 显示一个4.0版本Helptopics对话框。

    HELP_FORCEFILE / 0 / 用于保证WinHelp显示正确的Help文件,如果不是正确的显示,则装载正确的Help文件。

    HELP_INDEX / 0 / 该命令与4.0以前的版本相兼容。新的应用程序应该使用HELP_FINDER来代替。

    HELP_KEY / 关键字字符串的地址 / 显示由关键字标识的标题,关键字的地址由Data传递。

    HELP_PARTIALKEY / 关键字字符串的地址 / 如果完全匹配,则显示由关键字标识的主题,关键字的地址由Data传递,如果有一个以上的匹配,则显示Index标签。

    HELP_QUIT / 0 / 如果没有其他的应用程序请求Help,则将关闭Help应用程序。

    HELP_SETCONTENTS / 对Contents主题的上下文的标识符 / 当用户按击Contents按钮时,指定要显示的主题。

    HELP_SETINDEX / 对索引主题上下文的标识符 / 指定要在Index中显示的关键字列表。

    HELP_HELPONHELP / 0 / 使用Windows Help显示Help。


    HelpFile属性
    对应对象:TApplication
    声明:property HelpFile:String;
    功能:HelpFile属性指定应用程序所使用的Help文件名。 HelpFile属性在运行时是有效的,缺少时此值为空字符串。如果使用之前没有将HelpFile设置成为一个有效的文件名,则在调用了Help方法之后,应用程序将对此操作忽略。

    HelpJump方法
    对应对象:TApplication
    声明:function HelpJump(const JumpID:string):Boolean;
    功能:HelpJump方法用于打开一个Windows Help的指定的页。 HelpJump方法驱动Windows Help应用程序的WINHELP.EXE文件,并且打开了包含有JumpID参数所指定的上下文字符串的页。如果Application的HelpFile属性包含有一个有效的Help文件名的引用,则HelpJump将返回真,否则返回假。为了创建一个上下文字符串可以参考Mircosoft Help WorkShop用户手册。
    例子:

    procedure TForm1.mnuGotoHelpClick(Sender:TObject);
    begin
    Application.HelpFile:=’my_apps_help.hlp’;
    Application.HelpJump(hlpMyIdentifier);
    end;

    HintColor属性
    对应对象:TApplication
    声明:property HintColor:TColor;
    功能:HintColor属性用来确定在应用程序中出现的工具的提示窗口的颜色值。 HintColor属性确定了应用程序所使用的工具提示窗口的背景颜色,这个颜色可以被设置成为任何的系统支持的颜色。一些通用的颜色是clBlack,clWhite,clYellow,clCaption及clWindow。HintColor是运行时有效的属性。可以通过各种组件的Hint属性来访问提示。
    例子:

    procedure TForm1.FormCreate(Sender:TObject);
    begin
    Application.HintColor:=clAqua;
    Form1.Hint:=’The HintColor demo program’;
    Form1.ShowHint:=True;
    end;

    HintHidePause属性
    对应对象:TApplication
    声明:property HintHidePause:Integer;
    功能:当用户使用鼠标指针在显示的工具提示上没有立即移开时,HintHidePause属性用来确定工具提示的时间长短。 在缺少的情况时,工具的提示及在它消失之前显示约2500毫秒。用户可以用这个属性修改显示的时间长度,时间单位是毫秒。这个属性是在运行时有效的。可以使用每个组件的Hint属性来访问工具提示。
    例子:

    procedure TForm1.FormCreate(Sender:TObject(;
    begin
    //Set the HintHidePause to 5 seconds
    Application.HintHidePause:=5000;
    end;

    HintPause属性
    对应对象:TApplication
    声明:property HintPause:Integer;
    功能:HintPause属性用来指定在一个工具提示显示之前的所显示的时间长短。当鼠标在一个将被显示的工具提示之上停留一段时间后,工具提示才显示帮助。这个停留的时间可以由HintPause属性来确定,单位是以毫秒来计算。缺少蝗时间是800毫秒。一般可以使用每个组件的Hint属性来访问组件。
    例子:

    procedure TForm1.FormCreate(Sender:TObject);
    begin
    //Set the HintHidePause to 5 seconds
    Application.HintHidePause:=5000;
    //Set the HintPause to 1 second
    Application.HintPause:=1000;
    end;

    HintShortPause属性
    对应对象:TApplication
    声明:property HintShortPause:Integer;
    功能:HintShortPause属性用来确定在绘制之前工具提示的延迟时间的长短。 HintShortPause用于当用户移动鼠标经过了一系列的与工具提示相关联的组件时,禁止工具提示的快速绘制。它确定了工具提示在重新显示之前的等待的时间长短,如果工具提示在近期已经显示过并且鼠标指针再次移动到这个组件上时,HintShortPause将显示在工具再次显示之前的延迟的时间。这个属性在运行时是有效有,时间的单位是毫秒,在缺少时的值是50毫秒。工具提示可以通过组件的Hint属性访问。
    例子:

    procedure TForm1.FormCreate(Sender:TObject);
    begin
    //Set the HintPause to 1 second
    Application.HintPause:=1000;
    //Set the HintShortPause to 1/10th of a second
    Application.HintShortPause:=100;
    end;

    Icon属性
    对应对象:TApplication
    声明:property Icon:TIcon;
    功能:Icon属性确定一个代表应用程序的图标。
    每一个应用程序的图标Icon属性出现在应用程序任务栏窗口的按钮上,人微言轻应用程序主窗体标题栏的图标,并用来作为在文件浏览器中应用程序的图标。虽然图标的Icon属性可以使用代码来设置,但一般从Delphi中的Project Options对话框中的Application的标签中设置。如果没有改变在选项中的图标,那么当用户在Shell中查看时,可以为自己的应用程序获得缺少的“火炬”图标。
    例子:

    procedure TForm1.FormCreate(Sender:TObject);
    begin
    //Set the application icon
    Application.Icon.LoadFromFile(‘d:\Borland\Delphi 4\Images\Icons\Earth.ico’);
    end;

    Initialize方法
    对应对象:TApplication
    声明:procedure Initialize;
    功能:Initialize方法一般是应用程序调用的第一个方法。当用户建立了一个新的Delphi应用程序项目时,Initialize将自动地被添加到用户的项目资源上,如果用户的应用程序不是一个OLE自动化服务器,则用户可以删除初始化的这一行代码。对于OLE的自动化服务器,Initialize将使用系统寄存器来存储OLE自动化服务器的类。一个OLE自动化服务器是一个应用程序或一个DLL,它将OLE对象输送给OLE自动化客户。
    例子:

    program Project1;

    uses
    Forms,
    Unit1 in ‘Unit1.pas’{Form1};
    {$R *.RES}

    begin
    Application.Initialize;
    Applocation.Title:=’Delphi TApplication Demo Program’;
    Application.CreateForm(TForm1,Form1);
    Application.Run;
    end;

    MainForm属性
    对应对象:TApplication
    声明:property MainForm:TForm;
    功能:MainForm属性用来指示哪一个窗体是应用程序的主窗体。MainForm属性在运行时有效的,它是只读型的。主窗体是当应用程序被执行时被最先建立的窗体,当主窗体被关闭时应用程序也被关闭。主窗体可以通过项目选项对话框的窗体页来设置。
    例子:

    program Project1;

    uses
    Forms,
    Unit1 in ‘Unit1.pas’{Form1};
    Unit2 in ‘Unit2.pas’{Form2};
    {$R *.RES}

    begin
    Application.Initialize;
    Application.Title:=’MainForm Demo Program’;
    Application.CreateForm(TForm1,Form1);
    Application.CreateForm(TForm2,Form2);
    Application.Run;
    end;

    MessageBox方法
    对应对象:TApplication
    声明:function MessageBox(Text,Caption:PChar;Flags:Word):Integer;
    功能:MessageBox方法可以显示一个对话框,在对话框中包含了一条信息和一个及多个按钮。MessageBox方法是TApplication中的一个经常使用的方法,它包含了Windows API MessageBox函数。使用过Windows的朋友都看到过MessageBox,可以使用VB或Delphi来创建它们。以下是Flags允许的一些值的组合。

    标 记 值 / 意 义

    MB_ABORTRETRYIGNORE / 出现3个按钮:Abort,Retry,Ignore。

    MB_APPLMODAL / 对于应用程序的信息框是模式的,即当返回到应用程序之前用户必须单击一个键,MB_APPLMODAL由缺少值设置,对应的行为可以使用MB_SYSTEMMODAL或MB_TASKMODAL来改变。

    MB_DEFAULT_DESKTOP_ONLY / 信息框必须出现在缺少的桌面上,这个桌面是用户注册的桌面。

    MB_DEFBUTTON1 / 信息框的第一个按钮是缺省的按钮。

    MB_DEFBUTTON2 / 信息框的第二个按钮是缺省的按钮。

    MB_DEFBUTTON3 / 信息框的第三个按钮是缺省的按钮。

    MB_DEFBUTTON4 / 信息框的第四个按钮是缺省的按钮。

    MB_HELP / 在信息框上添加一个Help按钮,当按F1或此按钮时可以引起Help事件。

    MB_ICONASTERISK / 与MB_ICONFORMATION的相同。

    MB_ICONERROR / 与MB_ICONHAND相同。

    MB_ICONEXCLAMATION / 出现一个感叹号的图标。

    MB_ICONHAND / 与MB_ICONSTOP相同。

    MB_ICONINFORMATION / 出现一个小写的i图标。

    MB_ICONQUESTION / 出现一个问号?的图标。

    MB_ICONSTOP / 出现一个红色的叉子×的图标。

    MB_ICONWARNING / 与MB_ICONEXCLAMATION的相同。

    MB_OK / 信息框出现一个按钮,按钮标题是OK。

    MB_OKCANCEL / 信息框出现两个按钮,按钮标题是OK和Cancel。

    MB_RETRYCANCEL / 信息框出现两个按钮,按钮标题是Retry和Cancel。

    MB_RIGHT / 信息框内的信息是向右对齐的。

    MB_TRLREADING / 信息框内的文字对于Hebrew和Arabic系统来说是向右对齐的。

    MB_SERVICE_NOTIFICATION / 允许信息框在一个没有被注册的桌面上显示。

    MB_SETFORMEGROUND / 使信息框成为当前的窗口。

    MB_SYSTEMMODAL / 此信息框不允许用户在它被关闭之前进行任何的其他操作,这个标记可以为十分重要的信息进行保留。

    MB_TASKMODAL / 与MB_APPLMODAL相同。

    MB_YESNO / 信息框有两个按钮,按钮标题是Yes和No。

    MB_YESNOCANCEL / 信息框内有三个按钮,按钮标题是Yes,No和Canel。

    对于此属性的返回值类型可见下表:

    命名的返回值 / 返回数值 / 意 义

    IDABORT / 0 / 没有足够的内存空间来显示信息框。

    IDABORT / 3 / 用户选择了Abort按钮功能。

    IDCANCEL / 2 / 用户选择了Cancel按钮功能。

    IDIGNORE / 5 / 用户选择了Ignore按钮功能。

    IDNO / 7 / 用户选择了No按钮功能。

    IDOK / 1 / 用户选择了OK按钮功能。

    IDRETRY / 4 / 用户选择了Retry按钮功能。

    IDYES / 6 / 用户选择了Yes按钮功能。

    例子:

    //Close the application
    procedure TForm1.mnuFileQuitClick(Sender:TObject);
    begin
    if Application.MessageBox(‘Do you really want to quit?’,’Quit?’, MB_YESNO+MB_ICONHAND)=IDYES then Close;
    end;

    Minimize方法
    对应对象:TApplication
    声明:procedure Minimize;
    功能:Minimize方法使一个应用程序最小化成为一个任务栏按钮。 Minimize方法使应用程序的每一个窗口和当前窗口都变为最小化形式。
    例子:

    procedure TForm1.mnuMinimizeClick(Sender:TObject);
    begin
    Application.Minimize;
    end;

    OnActivate事件
    对应对象:TApplication
    声明:property OnActivate:TNotifyEvent;
    功能:OnActivate事件是在应用程序被激活时产生。当应用程序接受一个焦点时OnActivate事件将产生。由于它对应TApplication对象不能从对象探测器直接获得,所以要人工对应地创建一个OnActivate事件的处理代码。
    例子:

    unit Unit1;

    interface

    uses
    Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs;

    type
    TForm1=class(TForm);
    procedure FormCreate(Sender:TObject);
    //add these function declarations manually
    procedure AppActivate(Sender:TObject);
    procedure AppDeactivate(Sender:TObject);
    private
    {Private declarations}
    public
    {Piblic declarations}
    end;

    var
    Form1:TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.FormCreate(Sender:TObject);
    begin
    //determine which methods will handle OnActivate and OnDeactivate
    Application.OnActivate:=AppActivate;
    Application.OnDeactivate:=AppDeactivate;
    end;

    //Add this event handler manually
    procedure TForm1.AppActivate(Sender:TObject);
    begin
    //Perform task here thate you want to happen every time the application is activated.
    end;

    //Add this event handler manually
    procedure Tform1.AppDeactivate(Sender:TObject);
    begin
    //Perform task here that you want to happen every time the application is deactivated.
    end;

    end;

    OnDeactivate事件
    对应对象:TApplication
    声明:property OnDeactivate:TNotifyEvent;
    功能:OnDeactivate事件在应用程序推动焦点时将发生。OnDeactivate事件允许用户在应用程序无效之前结束任务。由于对应的TApplication对象不能在对象探测器中被获得,所以,用户需要人工地创建OnDeactivate事件的处理代码。
    例子:

    unit Unit1;

    interface

    uses
    Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs;

    type
    TForm1=class(TForm);
    procedure FormCreate(Sender:TObject);
    //add these function declarations manually
    procedure AppActivate(Sender:TObject);
    procedure AppDeactivate(Sender:TObject);
    private
    {Private declarations}
    public
    {Piblic declarations}
    end;

    var
    Form1:TForm1;

    implementation

    {$R *.DFM}

    procedure TForm1.FormCreate(Sender:TObject);
    begin
    //determine which methods will handle OnActivate and OnDeactivate
    Application.OnActivate:=AppActivate;
    Application.OnDeactivate:=AppDeactivate;
    end;

    //Add this event handler manually
    procedure TForm1.AppActivate(Sender:TObject);
    begin
    //Perform task here thate you want to happen every time the application is activated.
    end;

    //Add this event handler manually
    procedure Tform1.AppDeactivate(Sender:TObject);
    begin
    //Perform task here that you want to happen every time the application is deactivated.
    end;

    end;

    OnException事件
    对应对象:TApplication
    声明:property OnException:TExceptionEvent;
    功能:OnException事件在应用程序出现了一个无法处理的异常时发生。OnException事件类似于异常的全局else,如果用户不明显地处理一个异常,可以通过HandleException来发出OnException事件。缺省时HandleException将调用ShowException,并将出现异常的信息框。如果用户想改变对应的操作,可以对OnException事件添加处理代码。TExceptionEvent的类型是OnException,它可以被声明成为:TExceptionEvent=procedure (Sender:TObject;E:Exception) of Object;
    Sender参数声明了产生异常的对象,E参数是异常的信息。
    例子:

    unit Unit1;

    interface

    uses
    Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,StdCtrls;

    type
    TForml=class(TForm)
    Buttonl:Button;
    label1:Tlabel;
    procedure FormCreate(Sender:TObject);
    procdurc AppException(Sender:Tobect;E: Exception);
    procedure ButtonlClick(Sender:TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Fom1: TForml;
    X: Integer;

    implementation

    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.OnException:= AppException;
    X:=100;
    Iabell.Caption:=IntToStr(X);
    end;

    procedure TForml.AppException(Sender: Tobject;E: Exception);
    begin
    if Sender=Button1 then
    X:=0;
    end;

    procedure Tform1.Button1C1ick(Sender:TObject);
    var Y:Integer;
    begin
    Y:=0;
    try
    X:=X div Y;
    except
    on ErangeError do
    X:=0;
    end;

    end.

    OnHelp事件
    对应对象:TApplication
    声明: property OnHelp:THelpEvent;
    功能:OnHelp事件用于当用户程序出现并接到一个帮助请求时发出帮助。HelpContext和HelpJump方法用于产生OnHelp。如果用户想在每一个帮助执行时执行一些任务,可以创建OnHelp事件的事件处理代码。

    OnHint事件
    对应对象:TApplication
    声明:property OnHint:TNotifyEvent;
    功能:当一个指针处于一个组件上,此组件的Hint属性包含有一个有效字符串时,OnHint事件将发生。为了使OhHint事件发生,组件的Hint属性必须包含一个非空的字符串。用户可以使用OnHint事件来执行当该事件发生时用户希望发生的任务。一般情况时,应用程序利用事件窗体状态栏上的Hint字符或帮助信息。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,Dialogs,
    Buttons,ExtCtrls,ComCtrls;

    type
    TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    Panel1: TPanel;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    //manually added handler for the OnHint event
    procedure HandleHints(Sender:TObject);
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    //Set the OnHint event to be handled by HandleHints
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.OnHint:= HandleHints;
    end;

    //When an OnHint event occurs,display the hint in the status bar
    procedure Tform1.HandleHints(Sender:TObject);
    begin
    StatusBar1.SimpleText:=Application.Hint;
    end;

    end.

    OnIdIe事件
    对应对象:TApplication
    声明: property OnIdle: TIdleEvent;
    功能:在应用程序空闲时将发生OnIdle事件,如果用户想在应用程序空闲时处理一些操作,可以将一个事件处理代码添加到OnIdle事件上去。TIdleEvent的类型被声明成为OnIdLe,定义是:TidleEvent=procedure(Senger:Tobject; var Done: Boolean) of object; 其中Done参数缺省时为真,声明应用程序等待系统的信息。当Done参数为假时,应用程序将不处理系统信息。使用OnIdle事件要特别注意,许多应用程序不需要处理这个事件。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,Dialogs,
    ComCtrls,StdCtrls;

    type
    TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    procedure Waiting(Sender:TObject; var Done: Boolean);
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    //Setup an OnIdle event handler
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.OnIdle:= Waiting;
    end;

    //the handler for OnIdle events
    procedure Tform1.Waiting(Sender:TObject; var Done: Boolean);
    begin
    StatusBar1.SimplePanel:=True;
    StatusBar1.SimpleText:= ‘OK!Let‘s get going’;
    Done:=True;
    end;

    OnMessage事件
    对应对象:TApplication
    声明:TMessageEvent=procedure(var Msg: TMsg; var Handled: Boolean) of object;
    property OnMessage: TmessageEvent;

    功能:OnMessage事件在应用程序收到一个系统信息时被激发。如果用户想使应用程序对一个特定的信息作出一个特定的响应,则可以对OnMessage事件来创建一个对应的处理代码来完成。应用程序中的许多信息是被自动地处理并由Delphi来为用户传递,采用这个方法可以使用户使用API的方法处理信息。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls,ComCtrls;

    type
    TForm1 = class(TForm)
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    procedure MessageHandler(var Msg:TMsg; var Handled:Boolean);
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    //Determine the handler for OnMessage
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.OnMessage:=MessageHandler;
    end;

    //The OnMessage event handler
    procedure Tform1.MessageHandler(var Msg:TMsg;var Handled:Boolean);
    begin
    ListBox1.Items.Add(‘message recevied’);
    If ListBox1.Items.Count>15 then
    ListBox1.Clear;
    End;

    end.

    OnMinmize事件
    对应对象:TApplication
    声明: TNotifyEvent=procedure(Sender:Tobject) of object;
    property OnMinimize:TnotifyEvent;

    功能:当应用程序被最小化时将发生对应的OnMinimize事件。和一般的TApplication事件一样,当应用程序被最小化时,用户可以创建对应的特定的某些操作任务,并可以通过为OnMinimize事件添加一个特定的处理代码来实现。OnMinimize事件被激发,是由于Minimize方法被调用或应用程序的主窗口的最小化按钮被点击所造成的。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils , Classes, Graphics, Controls, Forms,Dialogs;

    type
    TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    //manully added method declarations
    procedure MinimizeHandler(Sender:TObject);
    procedure RestoreApp(Sender:TObject);
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    //Set custom handlers for the OnMinimize and OnRestore events
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.Title:=’My application’;
    Application.OnMinimize:=MinimizeHandler;
    Application OnRestore:=RestoreApp;
    end;

    //Change the app title back when the app is Minimized
    procedure Tform1.MinimizeHandler(Sender:TObject);
    begin
    Application.Title:=’Minimized!’;
    End;

    //Change the app title back when it is restore
    procedure Tform1.RestoreApp(Sender:TObject);
    begin
    Application.Title:=’My application’
    end;

    end.

    OnRestore事件
    对应对象:TApplication
    声明: TNotifyEvent=procedure(Sender:TObject) of object;
    property OnRestore:TNotifyEvent;

    功能:当一个最小化的应用程序被还原时,OnRestore事件发生。和一般的TApplication事件一样,当应用程序被还原时用户可以创建对应的任务操作,并可以处理对应的OnRestore事件的代码来完成特定的任务。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils , Classes, Graphics, Controls, Forms,Dialogs;

    type
    TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    //manully added method declarations
    procedure MinimizeHandler(Sender:TObject);
    procedure RestoreApp(Sender:TObject);
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    //Set custom handlers for the OnMinimize and OnRestore events
    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.Title:=’My application’;
    Application.OnMinimize:=MinimizeHandler;
    Application.OnRestore:=RestoreApp;
    end;

    //Change the app title back when the app is Minimized
    procedure Tform1.MinimizeHandler(Sender:TObject);
    begin
    Application.Title:=’Minimized!’;
    End;

    //Change the app title back when it is restore
    procedure Tform1.RestoreApp(Sender:TObject);
    begin
    Application.Title:=’My application’
    end;

    end.

    OnShowHint事件
    对应对象:TApplication
    声明:
    THintInfo=record
    HintControl:Tcontrol;
    HintPos: TPoint;
    HintMaxWidth: Integer;
    HintColor: TColor;
    CursorRect: TRect;
    CursorPos: TPoint;
    ReshowTimeout: Integer;
    HideTimeout: Integer;
    HintStr: string;
    end;

    TShowHintEvent = procedure (var HintStr: string; var CanShow: Boolean; var
    HintInfo: THintInfo) of object;
    property OnShowHint: TShowHintEvent;

    功能:当应用程序要显示一个工具提示时OnShowHint事件将发生。OnShowHint事件在工具提示被显示之前发生,因此这个事件允许用户在工具提示显示之前改变它对应的操作。TShowHintEvent是一个指针类型,它指向显示控件工具所提示的方法。工具提示的文字是由HintStr参数来提供的。如果CanShow参数是真,则工具提示可以显示。如果这个参数为假,则提示不能被显示。HintInfo参数的类型是THintInfo的,提示一个Pascal的记录。THintInfo记录中的内容确定了工具提示的属性。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    Dialogs,Buttons,ExtCtrls,ComCtrls;

    type
    TForm1 = class(TForm)
    Panel1: TPanel;
    StatusBar1: TStatusBar;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    SpeedButton4: TSpeedButton;
    SpeedButton5: TSpeedButton;
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
    public
    Procedure HandleHints(Sender:TObject);
    Procedure DoBeforeHint(var HintStr:String;var CanShow:Boolean;
    var HintInfo:THintInfo);
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Application.OnHint:=HandleHints;
    Application.OnShowHint:=DoBeforeHint;
    Application.Hint:='Hello,World!';
    end;

    Procedure TForm1.HandleHints(Sender:TObject);
    begin
    StatusBar1.SimpleText:=Application.Hint;
    end;

    Procedure DoBeforeHint(var HintStr:String;var CanShow:Boolean;var HintInfo:THintInfo);
    begin
    //If the hint is for the Abort button,display it in red
    if HintInfo.HintControl=SpeedButton5 then
    HintInfo.HintColor:=clRed;
    end;

    end.

    Restore方法
    对应对象:TApplication
    声明: procedure Restore;
    功能:Restore方法还原一个被最小化的应用程序。Restore方法被用于把主窗口还原成为它被最小化之前的大

    Run方法
    对应对象:TApplication
    声明: procedure Run;
    功能:Run方法用来执行应用程序。Run方法自动被每个Delphi应用程序所调用,一般在项目代码中它位于最后一行。
    例子:

    program Project1;

    uses
    Forms,
    Unit1 in 'Unit1.pas' {Form1};

    {$ R*.RES}

    begin
    Application.Initialize;
    Application.CreateForm(TForm1,Form1);
    Application.Run;
    end;

    Title 属性
    对应对象:TApplication
    声明:Property Title:string;
    功能:Title属性用来确定任务栏按钮中所标识应用程序的文字。Title属性可以具有一个与主窗体不同的标题,由此窗体经常具有和他的任务栏不同的标题。应用程序的标题可以使用Title属性来设置或者通过项目选项的应用页的IDE来确定,应用程序的缺省名可作为项目的名。如果用户没有重新命名,则应用程序将以PROJECT1被调用。
    例子:
    procedure TForm1.FormCreate(Sender:TObject);
    begin
    Application.title:='Chris-Travel Expense Report';
    Form1.Caption:= Application.Title;
    end;



    2003-11-14 14:39:00
    发表评语»»»

    2003-11-14 14:44:51 VCL组件的属性和方法详解 -- 二、TCommonDialog二、TCommonDialog
    继承关系:
    TCommonDialog--TColorDialog

    Color属性
    对应对象:TColorDialog
    声明:property Color:TColor default clBlack;
    功能:Color属性用来确定在颜色对话框中选择哪一个颜色。当用户选择了一个新的颜色时,Color属性将被设置为新颜色的值。
    例子:

    //Change the color of the selected text when the user choose a
    //color from the Color dialog box
    procedure TForm1.sbColorClick(Sender: TObject);
    begin
    Colordialog1.Execute;
    RichEdit1.SelAttributes.Color:=Colordialog1.Color;
    End;

    CustomColors属性
    对应对象:TColorDialog
    声明:property CustomColors:TStrings;
    功能:CustomColors属性确定在颜色对话框中可以获得的一种自定义的颜色。CustomColors属性保存了一个字符串的列表,每一个字符串的格式是:ColorX=HexValue,其中ColorX是16个自定义的颜色中的一个,是从ColorA到ColorP,HexValue参数是一个十六进制的数值,它说明了构成颜色的所对应的RGB值。所以,对应于纯白色这个值是FFFFFF,000000是纯黑,使用Color0=000000 说明了把纯黑色传递给颜色选择。当颜色对话框被关闭时,保存了对话框颜色的列表,以便用户可以在下一次使用对话框时使用自定义颜色。
    例子:

    procedure TForm1.sbColorClick(Sender: TObject);
    var X:Integer;
    begin
    Colordialog1.CustomColers:= StrCustomColors;
    Colordialog1.Execute;
    RichEdit1.SelAttributes.Color:=Colordialog1.Color;
    StrCustomColors:=Colordialog1.CustomColors;
    //Save StrCustomColors to the registry or an INI file
    //when the program exits…
    end;

    Options属性
    对应对象:TColorDialog
    声明: TColorDialogOption = (cdFullOpen, cdPreventFullOpen, cdShowHelp, cdSolidColor,cdAnyColor);
    TColorDialogOptions = set of TColorDialogOption;
    property Options: TcolorDialogOptions default[];
    功能:Options属性说明了颜色对话框的显示形式和选项。
    以下列举了有效的选项值。

    选 项 值 / 意 义

    cdFullOpen / 当颜色对话框被打开时显示了定制颜色的选项。

    cdPreventFullOpen / 使在对话框中的定义定制的颜色成为不可用,所以便用者不能定义新的颜色。

    cdShowHelp / 在对话框之中添加一个帮助按钮。

    cdSolidColor / 指引系统使用最近的纯颜色的选择。

    cdAnyColor / 允许使用者选择非纯的颜色(可以被近似的抖动)

    缺省时所有的选项是被关闭的。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    ColorDialog1.Options:=[ cdFullOpen, cdShowHelp];
    end;

    OnClose事件
    对应对象:TColorDialog
    声明:property OnClose:TNotifyEvent;
    功能:当一个对话框被关闭时,OnClose事件被引发。当对话框关闭时写入一个OnClose事件的句柄来完成指定的操作。




    2003-11-14 15:14:14 VCL组件的属性和方法详解 -- 三、TComponent 三、TComponent
    ComponentCount属性
    对应对象:所有组件
    声明:property ComponentCount: Integer;
    功能:此属性在运行时有效,它是只读型。同时它标明组件具有的组件数。当用户在设计时可以在窗体上放置一个组件,因此此窗体将变为这个组件的有用者。Components属性例出了当前组件的所有的组件。
    例子:

    procedure TForml.ButtonlClick(Sender: TObject);
    var
    x: Integer;
    begin
    x := Forml.ComponentCount;
    Labell.Caption := IntToStr(x);
    end;

    ComponentIndex属性
    对应对象:所有组件
    声明:properrty ComponentIndex: Integer;
    功能:此属性说明了拥有者的组件例表中当前的组件的位置。
    每个组件包含一个其拥有者的组件数组,此数组是以0为基底的数组。Components属性可以来访问这个数组。CompnentIndex属性列出了它被拥有者的Components数组内部组件的位置,该属性在运行时是有效的,且是只读型。
    例子:

    procedure TForm1.ButtonlClick(Sender: TObject);
    begin
    Labell.Caption := IntToStr(RadioButton3.ComponentIndex);
    end;

    Components属性
    对应对象:所有组件
    声明:property Components[Index: Integer]: TComponent;
    功能:Components属性指出当前数组所拥有的组件数组。
    Components属性在运行时是有效的,它是只读型的。它可以用来访问组件所拥有的任何组件(在知道组件的索引时)。一般情况下直接地访问组件边界容易,但是如果用户在运行时动态地创建了许多组件,用户将需要使用这个方法。因为组件数组是以0为基底的,所以第一个组件的索引将是0,第二个组件的索引将是1等。
    例子:

    //Indirectly access the check boxes owned by the form and check them all
    procedure TForml.Button3Click(Sender: TObject);
    var
    x: Integer;
    begin
    for x := 0 to Forml.ComponentCount – 1 do
    if Forml.Components[x] is TCheckBox then
    TCheckBox(Form1.Components[x]).Checked := True;
    end;

    ComponentState属性
    对应对象:所有组件
    声明:property ComponentState: TComponentState;
    功能:ComponentState属性用来描述组件的状态。
    ComponentState属性在运行时是有效的,且它是只读型的。它的类型是TComponentState,被声明成为:TComponentState = set of (csLoading, csReading, csWriting, csDestroying, csDesigning, csAncestor, csUpdating, csFixups); TComponentState是一个标志集合,把它们组合在一起可以导出组件的状态,一些公用的标志包括以下:
    csDesigning:Delphi环境是设计方式,因此可以编辑组件。
    csReading:组件从一个流中读取它的属性值。
    csWriting:组件将它的属性值写入一个流中。
    组件在内部使用CompnentState属性,可以保证某些程序可以执行。因此,无需经常直接地访问ComponentState。

    DestroyCompoents方法
    对应对象:所有组件
    声明:procedure DestroyComponents;
    功能:DestroyComponents方法撤销当前组件所拥有的全部组件。
    DestroyComponents是它在第—次调用Destroying之后由Destroy方法调用的。除非是设计一个组件,一般的情况下是不需要直接访问DestroyComponents的。

    Destroying方法
    对应对象:所有组件
    声明:procedure Destroying;
    功能:Destroying通过在它的ComponentState属性中设置cbDestroying标志,来通知当前组件立刻被撤销(除了在同时由全局TGovemor对象产生一个msgPardon信息)。之后它将对当前组件拥有的每一个组件调用Destroying方法。调用Destroying是由组件的Destroy方法所作出的第一个操作,用户一般不需要直接访问Destroying。

    FindComponent方法
    对应对象:所有组件
    声明:function FindComponent(const AName: string): TComponent;
    功能:FindComponent方法在当前的组件的Components数组中指出给定的组件。被传递给FindComponent中的字符串是被寻找的组件名。例如“Edit1”,“Label1”。FindComponent将返回该组件(如果它存在),否则将返回空。
    例子:

    //Use FindComponent to obtain another pointer to CheckBoxl
    procedure TForml.Button4Click(Sender: TObject);
    var
    MyComponent: TComponent;
    begin
    MyComponent := FindComponent(’CheckBox1’);
    TCheckBox(MyComponent).Checked := True;
    end;

    Name属性
    对应对象:所有组件
    声明:property Name: TComponentName;
    功能:Name是一个标识符、它可以用于在Delphi中的源代码和设计环境之间访问组件。De1phi在设计时为添加的组件提供了十分烦琐的缺省名,例如“Forml”,“Form2”等等。用户可以随意地改变它们。当动态的链接组件时,用户可以在源代码的var部分命名组件。
    例子:动态创建一个按纽控件。

    var
    Form2: TForm2;
    MyButton: TButton; //the Name property is MyButton

    implementation

    {$R *.DFM}

    procedure TForml.FormCreate(Sender: TObject);
    begin
    MyButton := TButton.Create(Self);
    MyButton.Parent := Form1;
    MyButton.Height := 32;
    MyButton.Width := 40;
    MyButton.Caption := ’Hi’;
    //set other button properties as needed
    end;

    警告:在运行时不要改变设计时创建的组件名。Delphi保持对设计时添加的组件方法和事件处理程序的跟踪,在程序运行时改变组件名将导致一些难以应付的事故。

    Owner属性
    对应对象:所有组件
    声明:property Owner: TComponent;
    功能:Owner属性用来指出当前组件的拥有者。
    一个窗体对应所有在其上面的组件是它们的拥有者。当一个组件的拥有者被撤销时,它的存储空间同时被释放,那么该组件也就被撤销了,它所占据的内存也被释放。拥有一个组件和作为一个组件的父类是不同的。控件(它是TComponent的派生类)具有一个Parent属性,是对应组件的视觉容器而不是说明它是拥有者。视觉容器像其他包含的控件面板一样,都没有拥有控件,包含的控件仍旧由窗体所拥有。当动态创建组件时,Owner属性由Create方法来设置,在设计时创建的组件将它的Owner属性设置成为当前的窗体。Owner属性在运行时是有效的。

    Tag属性
    对应对象:所有组件
    声明:property Tag: Longint;
    功能:Tag属性用组件存储一个用户定义的长整型值。Tag属性允许用户使用组件存储长整型值,当用户看到它合适时就可以使用它,它的使用是可以选择的。


    2003-11-14 15:35:49 VCL组件的属性和方法详解 -- 四、TControl四、TControl

    Align 属性
    对应对象:TControl
    声明:TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient);
    property Align: TAlign;
    功能:Align属性用来确定控件在它的父类中的对齐方式。 Align属性的类型是TAlign,它可以被设置成为以下值中的一个。

    值 / 意 义

    alNone / 组件被保持在它的父类放置的位置,即窗体或面板,它是属性的缺省值。

    alTop / 组件被移动到窗体的顶端,并且被重新决定大小以充满窗体的宽,组件的高度不会受到影响。

    alBottom / 组件被移动到窗体的底端,并且被重新决定大小以充满窗体的宽,组件的高度不会受到影响。

    alLeft / 组件被移动到窗体的左边,并且被重新设定大小以充满窗体的高度,组件的宽度不会受到影响。

    alRight / 组件被移动到窗体的右边,并且被重新设定大小以充满窗体的高度,组件的宽度不会受到影响。

    alClient / 组件被重新决定大小以充满一个窗体的用户区。如果另一个组件已经占据了用户区的部分,那么组件将重新在用户区中的剩余部分中设定大小。

    BoundsRect 属性
    对应对象:TControl
    声明:TRect = record
    case Integer of
    0: (Left, Top, Right, Bottom: Integer);
    1: (TopLeft, BottomRight: TPoint);
    end;
    property BoundsRect: TRect;
    功能:BoundsRect属性用来指出控件的边界的矩形。 BoundsRect属性包含了描述控件父类区域的边界的矩形。矩形的坐标是在父类坐标系中给定。

    Caption 属性
    对应对象:TControl
    声明:
    TCaption = type string;
    property Caption: TCaption;
    功能:Caption属性用来确定用于标记控件的字符串。 控件的标题可以被修改,但在运行时却很少被修改。由于Caption属性对用户禁止编辑,所以要允许用户编辑显示在控件中的文字的控件,应使用Text属性而不是Caption属性。Caption属性的类型为TCaption,它是一个标准的字符串。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Form1.Caption := ‘Delphi Explorer’;
    Button1.Caption := ‘OK’;
    Label1.Caption := ‘Captions are relatively static’;
    end;

    ClientHeight 属性
    对应对象:TControl
    声明:property ClientHeight: Integer;
    功能:ClientHeight属性用来说明控件用户区的高度。 ClientHeight属性对应除窗体之外的所有控件运行时的属性。它用像素来进行度量,许多控件与ClientHeight属性具有相同的高度值。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    var
    X, Y: Integer;
    begin
    X := Form1.ClientWidth;
    Y := Form1.ClientHeight;
    //...
    end;

    ClientOrigin 属性
    对应对象:TControl
    声明:TPoint = record
    X: Longint;
    Y: Longint;
    end;
    property ClientOrigin: TPoint;
    功能:ClientOrigin属性说明包含控件的用户区的左上角的坐标值。 ClientOrigin属性包含了控件用户区的上部左边的像素的坐标值,坐标是以屏幕的坐标值进行度量。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    var
    OriginPoint: TPoint;
    begin
    OriginPoint := Form1.ClientOrigin;
    end;

    ClientRect 属性
    对应对象:TControl
    声明:TPoint = record
    X: Longint;
    Y: Longint;
    end;
    TRect = record
    case Integer of
    0: (Left, Top, Right, Bottom: Integer);
    1: (TopLeft, BottomRight: TPoint);
    end;
    property ClientRect: TRect;
    功能:ClientRect属性说明了包含有控件的用户区的尺寸大小。 ClientRect属性是运行时有效,是只读型的。属性包含了控件用户区的边界上下左右的像素位置,对应TRect类型结构区域的左边和上部的坐标值是0,对应的下边和右边的像素值说明了区域的高度和宽度。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Form1.Canvas.Brush.Color := clBlue;
    Form1.Canvas.FillRect(Form1.ClientRect);
    end;

    ClientWidth 属性
    对应对象:TControl
    声明:property ClientWidth: Integer;
    功能:ClientWidth属性说明包含控件用户区的宽度。
    ClientWidth属性是对应除窗体之外的所有控件都有效运行时的属性。该属性表示了控件用户区的水平大小,宽度以像素来度量。对于许多控件ClientWidth属性和Width属性是一致的,而窗体则将用户区视为窗体框架内的成分,窗体的ClientWidth属性通常将小于Width属性的值。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    var
    X, Y: Integer;
    begin
    X := Form1.ClientWidth;
    Y := Form1.ClientHeight;
    //...
    end;

    Color 属性
    对应对象:TControl
    声明:property Color: TColor;
    功能:Color属性用来确定控件的颜色。
    用户可以使用Color属性来获得颜色或设置控件的颜色。用户可以通过手工来为控件的颜色属性赋予一个值进行重新设置。Color属性是TColor类型的值,它有许多有效的颜色值可以使用,详情见下表。

    值 / 颜 色

    clBlack / 黑色Black。

    clMaroon / 栗色Maroon。

    clGreen / 绿色Green。

    clOlive / 橄榄绿Olive green。

    clNavy / 深蓝色Navy blue。

    clPurple/ 紫色Purple。

    clTeal / 深青色Teal。

    clGray / 灰色Gray。

    clSilver / 银色Silver。

    clRed / 红色Red。

    clLine / 浅绿色Lime green。

    clBlue / 蓝色Blue。

    clFuchsia / 紫红色Fuchsia。

    clAqua / 浅绿色Aqua。

    clWhite / 白色White。

    clBackground / 当前的系统桌面的背景颜色

    clActiveCaption / 当前的被激活窗口的标题栏的颜色。

    clInactiveCaption / 当前的没有被激活的窗口的标题栏的颜色。

    clMenu / 当前的菜单背景的颜色。

    clWindow / 当前的窗口背景的颜色。

    clWindowFrame / 当前的窗口框架的颜色。

    clMenuText / 当前的菜单上的文本的颜色。

    clCaptionText / 当前的被激活窗口的标题栏的文本的颜色。

    clActiveBorder / 当前的被激活窗口的边界颜色。

    clInactiveBorder / 当前的没有被激活窗口的边界颜色。

    clAppWorkSpace / 当前的应用程序工作区的颜色。

    clHighlight / 当前的被选择文本的背景颜色。

    clHighlightText / 当前的被选择文本的颜色。

    clBtnFace / 当前的按钮表面的颜色。

    clBtnShadow / 当前的按钮投影的阴影颜色。

    clGrayText / 当前的无效文本的颜色。

    clBtnText / 当前的按钮上文本的颜色。

    clInactiveCaptionText / 当前的被激活窗口标题栏的文本颜色。

    clBtnHighlight / 当前的按钮上高亮度的颜色。

    cl3DDkShadow / 只有对Windows95或NT4.0系统:三维显示元素阴影的颜色。

    cl3DLight / 只有对Windows95或NT4.0系统:对于三维显示元素的亮面(朝向光源的面)

    clInfoText / 只有对Windows95或NT4.0系统:ToolTip(工具提示)的文本颜色。

    clInfoBk / 只有对Windows95或NT4.0系统:ToolTip(工具提示)的背景颜色

    ControlState 属性
    对应对象:TControl
    声明:TControlState = set of (csLButtonDown, csClicked, csPalette, csReadingState, csAlignmentNeeded, csFocusing, csCreating);
    property ControlState: TControlState;
    功能:ControlState属性用来查询控件运行时的状态。
    ControlState属性用来指明运行的每一个时刻控件的状态。属性属于TControlState类型,这个类型是一个标志集,它可以被设置成为以下值的组合形式。

    值 / 意 义

    csLButtonDown / 点击鼠标的左按钮不放,这个是为所有的鼠标按下事件设置的。

    csClicked / 和csLButtonDown一样,只是在ControlStyle属性包含csClickEvents标志时它才被设置,以说明鼠标按下时的事件。

    csPalette / 说明一个WM_PALETTCHANGED信息被控件接受或者被控件的父类接受。

    csReadingState / 控件正在从一个流中读取它的状态。

    csAlignmentNeeded / 当队列再次被允许时控件需要重新排列它自己。

    csFocusing / 应用程序过程焦点送给控件。这不能保证控件就将收到焦点,但是防止了递归的调用。

    csPaintCopy / 控件被复制,意味着控件的拷贝被打印,控制风格标记csReplicatable必须被设置为该状态的发生。

    csCreating / 框架和它的所有者发生“与”或者“或”的逻辑,并且控件被创建了。这个标记将在所有的创建动作完成时被清除。

    ControlStyle 属性
    对应对象:TControl
    声明:TControlStyle = set of (csAcceptsControls, csCaptionMouse, csDesignInteractive, csFramed, csClickEvents, csSetCaption, csOpaque, csDoubleClicks, csFixedWidth, csFixedHeight, csNoDesignVisible, csReplicatable, csNoStdEvents, csDisplayDragImage, csReflector);
    property ControlStyle: TControlStyle;
    功能:ControlStyle属性用来说明激活一个控件的哪些属性。
    ControlStyle属性方式被改变的次数比相应ControlState属性的标记要少。ControlStyle属性属于TControlStyle的类型,它可以是以下值的组合。

    值 / 意 义

    csAcceptsControls / 接受上面的控件。

    csCaptureMouse / 当这个事件发生时,控件捕获鼠标的事件。

    csDesignInteractive / 控件在设计时将鼠标按钮的右击映射为鼠标按钮的左击来控制控件。

    csClickEvents / 控件可以接受并且对按击的操作进行反应。

    csFramed / 控件有一个三维框架。

    csSetCaption / 如果标题还没有被明确地设置成为其他的内容时,控件将改变它的标题以便和Name属性相匹配。

    csOpaque / 控件将用户区的矩形设为透明。

    csDoubleClicks / 控件可以对鼠标的双击操作进行接受和反应,此外可以将双击映射成为按击操作。

    csFixedWidth / 控件的宽度设为固定值。

    csFixedHeight / 控件的高度设为固定值。

    csNoDesignVisible / 在设计时控件是不可以变化的。

    csReplicatable / 控件可以通过使用PaintTo方法,从而被拷贝到任意一个画面上进行绘制。

    csNoStdEvents / 标准事件,例如鼠标、键盘、点击事件均被忽略。如果用户的代码不需要对这些事件进行反应或者希望用户的应用程序运行更快时将使用这个设置来处理。

    csDisplayDragImage / 当鼠标被拖动到控件上面时,控件可从一个图像列表中显示一个图像。使用这个设置可使控件使用一个图像的列表。

    csReflector / 控件将对系统对话框信息、焦点信息及尺寸改变信息进行反应,如果控件被运作一个ActiveX的控件时使用这个设置,可使控件接受这些事件的通知。

    Cursor 属性
    对应对象:TControl
    声明:TCursor = -32768~32767;
    功能:Cursor属性用来确定当鼠标在控件上进行拖动时,将显示什么样的鼠标图形。Cursor属性属于TCursor类型变量,它包含了用户可以使用的许多标准的鼠标形式,并包含了以下的有效值:crDefault,crArrow,crNone,crCross,crIBeam,crSize,crSizeNESW,crSizeNS,crSizeNWSE,crSizeWE,crUpArrow,crHourGlass,crDrag,crNoDrop,crHSplit,crVSplit,crMultiDrag,crSQLWait,crNo,crAppStart,crHelp和crHandPoint,每个值对应的鼠标图像可以参考有关函数。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    Button1.Cursor := crCross;
    Panel1.Cursor := crArrow;
    end;

    DesktopFont 属性
    对应对象:TControl
    声明:property DesktopFont: Boolean;
    功能:DesktopFont属性说明当写入文本时,控件是否使用系统的桌面的字体。

    DragCursor 属性
    对应对象:TControl
    声明:TCursor = -32768~32767;
    property DragCursor: TCursor;
    功能:DragCursor属性用来确定鼠标在拖动时的形式。
    在DragCursor属性有效之前用户必须首先设置控件接受下拉时的对象,实际上用户只需处理一个诸如OnDragOver的拖放事件便可实现。
    例子:

    //Change the cursor shape if an object is dragged over the panel
    procedure TForm1.Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
    State: TDragState; var Accept: Boolean);
    begin
    Panel1.DragCursor := crDrag;
    end;

    DragMode 属性
    对应对象:TControl
    声明:TDragMode = (dmManual, dmAutomatic);
    property DragMode: TDragMode;
    功能:DragMode属性用来确定控件被拖动时的行为。
    DragMode属性属于TDragMode类型变量。这个类型有两个有效的值,即两个有效的拖动方式,dmAutomatic:如果dmAutomatic被选择作为拖动形式,则控件可被拖动,并且用户可以随时地点击和拖动控件。dmManual:如果dmManual被选择为其拖动的方式,直到控件调用了BeginDrag方法,控件才可以被拖动。
    例子:

    procedure TForm1.FormCreate(Sender: TObject);
    begin
    //...
    Form1.DragMode := dmAutomatic;
    Panel1.DragMode := dmAutomatic;
    end;

    Enabled 属性
    对应对象:TControl
    声明:property Enabled: Boolean;
    功能:Enabled属性用来确定控件对鼠标、键盘及Timer事件是否将作出反应。
    如果Enabled属性被设置为真,那么控件将对用户的鼠标、键盘输入及Timer事件作出反应。如果Enabled属性被设置为假,那么控件将变成灰色并且对鼠标、键盘及Timer事件不作反应。一般当控件的功能与当前状态无关时,可将该属性设置为假。

    Font 属性
    对应对象:TControl
    声明:property Font: TFont;
    功能:Font属性用来确定控件上文字的字体。
    Font属性允许用户对控件的文本和标题的字体的属性,选择各种有效的字体。字体属性包含颜色、名称、尺寸大小及风格。
    例子:

    with Form1.Font do
    begin
    Size := 12;
    Name := ‘Arial’;
    Color := clGreen;
    Style := [fsBold];
    end;

    Height 属性
    对应对象:TControl
    声明:property Height: Integer;
    功能:Height属性说明控件高度的尺寸大小。
    Height属性以屏幕的像素作为尺寸的度量,指明控件的高度值。
    例子:

    procedure TForm1.FormPaint(Sender: TObject);
    begin
    Panel1.Top := 10;
    Panel1.Left := 10;
    Panel1.Height := Form1.ClientHeight – 20;
    Panel1.Width := Form1.ClientWidth – 20;
    end;

    Hint属性
    对应对象:Tcontrol
    声明:property Hint:string;
    功能:Hint属性用来说明当光标停止在控件上时将出现工具提示窗口内容。为了使工具能够提示所显示得文字,必须将包含了工具得窗体控件的ShowHint属性为真。如果窗体和控件的ShowHint属性被设置为真,但是没有设置控件Hint属性,那么工具将显示控件父类的Hint的文字。

    IsControl属性
    对应对象:TControl
    声明:property lsControl:Boolean;
    功能:IsControl 属性用来决定一个窗体是否存储了它的特别属性。

    Left 属性
    对应对象:Tcontrol
    声明:property Left:Integer;
    功能:Left属性用来说明控件左边界的水平坐标。Left属性指出控件离它的容器的左边边界是多少象素,并使用屏幕坐标来度量一个窗体的Left属性值。

    MouseCapture属性
    对应对象:Tcontrol
    声明:property MouseCapture:Boolean;
    功能:MouseCapture属性说明控件是否已经俘获了鼠标事件。

    Name属性
    对应对象:TControl
    声明:TcomponentName:string;
    propertyName:TComponentName
    功能:属性是控件的名,它是可作为一个控件的新名或者用来指出控件的名。

    Parent属性
    对应对象:TControl
    声明:property Parent:TwinControl;
    功能:属性用来指出控件的父类(容器)。控件的父类是可视的,包含了控件的窗口控件。控件在它的父类被撤消时将被自动地撤消。

    ParentColor属性
    相应对象:TControl
    声明:property ParentColor:Boolean;
    功能:ParentColor属性用来确定控件是否将使用父类的颜色值,即Color值。如果ParentColor属性设置为真,那么控件将使用它父类的Color属性的颜色。如果ParentColor属性设置为假,那么控件将使用自己确定的Color属性的颜色值。

    ParentFont属性
    对应对象:TControl
    声明:property ParentFont:Boolean;
    功能:ParentFont属性用来确定控件是否使用父类的Font信息的属性值。如果ParentFont属性设置为真,那么控件将使用它父类的Font属性的字体。如果ParentFont属性设置为假,那么控件将使用自己确定的Font属性的字体属性值。

    ParnetShowHint属性
    对应对象:TControl
    声明:property ParentShowHint:Boolean;
    功能:ParentShowHint用来确定控件是否使用它的父类的ShowHint属性用来显示一个工具的提示。如果ParentShowHint属性设置为真,那么控件将使用它父类的ShowHint属性,以确定此控件是否将显示一个工具提示。如果ParentShowHint属性设置为假,则控件将使用自己定义的ShowHint属性的值以确定控件是否将显示一个工具提示。

    PopupMenu属性
    对应对象:TControl
    声明:property PopupMenu:TpopupMenu;
    功能:PopupMenu属性用来确定当用户右击控件区时,将对应地弹出哪种弹出式菜单。用户可以通过右击控件,来实现对应弹出式菜单的打开操作,用户可以通过调用弹出式菜单的Popup的方法来打开弹出式菜单。
    例子:

    procedure Tform1.FormCreate(Sender:Tobject);
    begin
    Form1.PopupMenu:=PopupMenu1;
    //..
    end;

    //Exit the appllication when the Exit pop-up menu items is clicked
    procedure Tform1.PopUpExitClick(Sender:Tobject);
    begin
    Close;
    end;

    ScalingFlags 属性
    对应对象:TControl
    声明:TscalingFlags=set of (sfLeft,sfTop,sfWidth,sfHeight,sfFont);
    property ScalingFlags:TscalingFlags;
    功能:ScalingFlags属性反应出控件的哪一个属性还没有进行尺度的计算。
    ScalingFlags属性是一个内部标记的集合,首先在计算继承的窗体和控件的缩放比例时被使用。要是没有必要,应用程序将不使用这个属性。以下是标记和它们对应所表达的信息意义:

    标记 / 意 义

    SfLeft / 控件的左边没有被进行尺寸计算缩放。

    SfTop / 控件的顶端没有被进行尺寸计算缩放。

    SfWidth / 控件的宽度没有被进行尺寸计算缩放。

    SfHeight / 控件的高度没有被进行尺寸计算缩放。

    sfFont / 控件的字体没有被进行尺寸计算缩放。

    ShowHint属性
    对应对象:TConcrol
    声明:property ShowHint:Boolean;
    功能:ShowHint属性用来确定控件是否显示一个工具提示。如果ShowHint属性被设置为真,那么当鼠标或光标停留在控件上时,将会显示出一个具有Hint属性的中文内容的工具提示。如果ShowHint属性被设置为假,同时ParentShowHint属性的值是假,那么将不显示工具的提示,但当ShowHint属性被设置为假ParentShowHint属性的值为真时,工具提示将依据其父类的ShowHint属性,如果父类的ShowHint属性是真,工具提示将显示,否则将不出现提示。ShowHint属性的缺省的值是真。
    例子:

    procedure Tform1.FormPaint(Sender:Tobject);
    begin
    btnHideMenu.ShowHint:=True;
    btnHideMenu.Hint:=’Click here to enable menus’;
    end;

    Text 属性
    对应对象:TControl
    声明:Tcaption:=type string;
    property Text:Tcaption;
    功能:Text属性用来确定控件中出现的用户编辑的文字内容。在运行是可以在程序中对文字进行修改,但却很少这样作。由于Caption的属性,用户是不能编辑的,所以不允许用户编辑的控件所显示的文字将是Caption的属性。

    Top 属性
    对应对象:TControl
    声明:property Top:Integer;
    功能:Top属性用来确定控件左上方的坐标值。Top属性是一个使用了容器坐标的属性。它说明控件的边界距离容器的边界有多少象素,并且窗体的Top属性以及屏幕坐标进行度量。

    Visible 属性
    对应对象:TControl
    声明:property Visible:Boolean;
    功能:Visible属性用来确定控件是否是可见。如果Visible属性为真,那么将是可见的。如果Visible属性为假,则是不可见的。

    Width 属性
    对应对象:TControl
    声明:property Width:Integer;
    功能:Width属性说明了控件的宽度值。用户象素值指出控件的水平大小。用户可以在运行时修改Width属性值来改变控件的宽度。
    例子:参见Height属性例子。

    WindowProc 属性
    对应对象:TControl
    声明:TwndMethod=procedure ( var Message:Tmessage) of object;
    property WindowProc:TwndMethod;
    功能:WindowProc属性包含了窗口的过程,过程是对传送给控件信息的一种反应。

    BeginDrag 方法
    对应对象:TControl
    声明:procedure BeginDrag(Immediate:Boolean);
    功能:BeginDrag方法在控件被手工拖动时有效,BeginDrag方法用来启动一个控件的拖动过程。Immediate参数用来确定拖动操作的条件,如果Immediate参数为真,那么拖动将立即实行,同时鼠标将变为拖动设置时的形式,如果Immediate参数为假,鼠标将不改变,只是当鼠标在空间上移动了5个象素时才开始进行拖动的操作。

    BringToFront 方法
    对应对象:TControl
    声明:procedure BringToFront;
    功能:BringToFront方法用来改变控件轴的次序,并吧它放置在所有其他控件的上面。每一个窗口和非窗口的控件都有对应的Z轴次序。每个窗体上的窗口控件都在相同的Z轴次序上,每个非窗口的控件在一个独自的Z轴次序集合中。一个窗体上的所有窗口控件存在于一个Z轴次序集合中,所有的非窗口控件在另一个的Z轴次序集合中。窗口的控件总是出现在非窗口控件的上面,窗口控件下面的非窗口的控件将不能使用BringToFront方法出现在窗口控件的上面。
    例子:

    procedure Tform1.Button2Click(Sender:Tobject);
    begin
    Button1.BringToFront;
    end;

    ChangeScale 方法
    对应对象:TControl
    声明:procedure ChangeScale(M,D:Integer);dynamic;
    功能:ChangeScale方法改变空间的大小,并依据一个指定的比例值来进行。

    Click 方法
    对应对象:TControl
    声明:procedure Click:dynamic;
    功能:Click方法调用与事件关联的控制事件的句柄。

    ClientToScreen 方法
    对应对象:TControl
    声明:Tpoint=record
    X:Longint;
    Y:Longint;
    End;
    Function ClientToScreen(const Point:Tpoint):Tpoint;
    功能:方法将控件坐标上的一个点的坐标值转换成屏幕坐标的值。
    例子:

    procedure Tform1.FormCreate(Sender:Tobject);
    var
    ButtonPos:Tpoint;
    Begin
    ButtonPos:=Button1.ClientToScreen(Point(Button1.Left,Button1.Top));
    //…
    End;

    Create 方法
    对应对象:TControl
    声明:constructor Create(Aowner:Tcomponent);override;
    功能:Create方法用来创造一个TControl的事件。

    DefaultHandler 方法
    对应对象:TControl
    声明:
    //DefaultHandler provides message handling for all messages that a control does
    //not have specific handlers for.
    Procedure DefaultHandler(var Message);override;
    功能:DefaultHandler方法用来当一个控件没有指明处理时,提供了对所有信息的缺省处理。

    DoEndDrag 方法
    对应对象:TControl
    声明:procedure DoEndDrag (Target:Tobject);X,Y:Integer);dynamic;
    功能:DoEndDrag方法提供了对一个控件的OnEndDrag事件进行保护实施的方法。

    DragCanceled 方法
    对应对象:TControl
    声明:procedure DragCanceled;dynamic;
    功能:DragCanceled方法除了提供对一个拖动进行取消反应外没有其他的操作。

    DragOver 方法
    对应对象:TControl
    声明:
    TdragState=(dsDragEnter,dsDragLeave,dsDragMove);
    procedure DragOver (Source:Tobject;X,Y:Integer;State:TdragState;var Accept:Boolean);dynamic;
    功能:DragOver方法调用OnDragOver事件的句柄。设置Accept参数为真时将说明使用者可以在控件上放置被拖动的对象,当Accept参数为假时,说明用户不能在控件上放置被拖动的对象到。Source参数时被拖动的对象,以下时可能有效的State参数值。

    值 / 意 义

    DsDragEnter / 鼠标正在进入控件。

    DsDragMove / 鼠标在控件上移动。

    dsDragLeave / 鼠标离开控件。

    EndDrag 方法
    对应对象:TControl
    声明:procedure EndDrag(Drop:Boolean);
    功能:EndDrag方法将终止一个控件被进一步的拖动。如果Drop参数为真,那么可以放下控件,如果Drop参数为假,控件将不能被放下,拖动的操作将被取消。

    GetClientOrigin 方法
    对应对象:TControl
    声明:function GetClientOrigin:Tpoint;virtual;
    功能:GetClientOrigin方法获得一个控件用户区左上角屏幕的坐标值。

    GetClientRect 方法
    对应对象:TControl
    声明:Trect=record
    case integer of
    0: (Left,Top,Right,Botton:Integer);
    1: (TopLeft,BottonRight:Tpoint);
    end;
    function GetClinetRect:Trect;virtual;
    功能:GetClinetRect方法返回一个矩形,以用来定义控件的用户区。

    GetDeviceContext 方法
    对应对象:TControl
    声明:function GetDeviceContext( var WindowHandle:HWnd):Hdc;virtual;
    功能:GetDeviceContext方法返回一个设备的上下文。

    GetDragImages 方法
    对应对象:TControl
    声明:function GetDragImages:TcustomImageList;virtual;
    功能:GetDragImages方法返回控件的图象列表,列表中包含了当拖动时被显示的图像。

    GetPalette 方法
    对应对象:TControl
    声明:funciton GetPalette:HPALETTE;dynamic;
    功能:GetPalette方法返回一个调色板的句柄,它被控件所使用。

    GetParentComponent 方法
    对应对象:TControl
    声明:funciton GetParentComponent:Tcomponent;override;
    功能:GetParentComponent方法返回控件父类的组件。

    GetPopupMenu 方法
    对应对象:TControl
    声明:function GetPopupMenu:TpopupMenu;dynamic;
    功能:GetPopupMenu方法获得一个控件的弹出式菜单。

    GetTextBuf 方法
    对应对象:TControl
    声明:function GetTextBuf ( Buffer:Pchar;BufSize:Integer):Integer;
    功能:GetTextBuf方法用来获得控件所包含的文字,并且将文字拷贝到一个缓冲区中。GetTextBuf方法从控件中获得文字,并把它作为一个以空字符结束的字符串拷贝到Buffer指定的缓冲区内。BufSize参数用来说明缓冲区的大小,在调用GetTextBuf方法之前使用GetTextLen方法进行设置。文字作为一个以空字符结尾的字符串被拷贝到缓冲区中。
    例子:

    procedure Tform1.Button2Click(Sender:Tobject);
    var
    MyBuffer:Pchar;
    MyBufSize:Integer;
    Begin
    MyBufSize:=Button1.GetTextLen;
    Button1.GetTextBuf(MyBuffer,MyBufSize);
    StatusBar1.SetTextBuf(MyBuffer);
    End;

    GetTextLen 方法
    对应对象:TControl
    声明:function GetTextLen:Integer;
    功能:GetTextLen方法用来检索控件文字的大小。GetTextLen方法一般在调用GetTextBuf方法之前使用,以便确定缓冲区的大小。使用GetTextLen方法可以代替字符串的处理函数。
    例子:

    procedure Tform1.Button2Click(Sender:Tobject);
    var
    MyBuffer:Pchar;
    MyBufSize:Integer;
    Begin
    MyBufSize:=Button1.GetTextLen;
    Button1.GetTextBuf(MyBuffer,MyBufSize);
    StatusBar1.SetTextBuf(MyBuffer);
    End;

    HasParent 方法
    对应对象:TControl
    声明:function HasParent:Boolean;override;
    功能:HasParent方法用来说明控件是否有一个父类。

    Hide 方法
    对应对象:TControl
    声明:procedure Hide;
    功能:Hide方法使一个控件变为不可视的。在Hide方法把控件的Visible属性设置为假 时,可使控件变的不可件的。
    例子:

    //If the “Hide menus” menu item is clicked,hide the forms menus but make the
    //”show menu” button visible so the user can turn the menu on again if necessary
    procedure Tform1.menuHideMenu1Click(Sender:Tobject);
    begin
    BtnHideMenu.Hide;
    Form1.Menu:=nil;
    End;
    // If the “Show menu” button is clicked,hide the button and show the form’s main
    menu

    procedure Tform1.btnShowMenuClick(Sender:Tobject);
    begin
    From1.Menu:=MainMenu1;
    BtnHideMenu.Hide;
    end;

    Invalildate 方法
    对应对象:TControl
    声明:procedure Invalidate;virtual;
    功能:Invalidate方法使控件对本身进行再次绘制。在调用Invalidate方法时应该尽快地重新绘制控件,Invalidate方法有Refresh调用。
    例子:

    procedure Tform1.Button1Click(Sender:Tobject);
    begin
    //Invalidate the form so that it can be repainted
    Form1.Intevalidate;
    Form1.Canvas.Repaint;
    end;

    MouseDown 方法
    对应对象:TControl
    声明:TmouseButton=(mbleft,mbRight,mbMiddle);
    TshiftState=set of (ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble);
    Procedure MouseDown (Button:TmouseButton;Shift:TshiftState;X,Y:Integer);
    Dynamic;
    功能:MouseDown方法调用OnMouseDown事件的句柄。

    MouseMove 方法
    对应对象:TControl
    声明:TshiftState=set of (ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble);
    procedure MouseMove(Shift:TshiftState;X,Y:Integer);dynamic;
    功能:MouseMove方法调用连接到OnMouseMove事件的句柄。

    MouseUp方法
    对应对象:Tcontrol
    声明:TmouseButton=(mbLeft,mbRight,mbMiddle);
    TshiftState=set of (ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble);
    Procedure MouseUp(Button:TmouseButton;Shift:TshiftState;X,Y:Integer); Dynamic;
    功能:MouseUp方法调用了OnMouseUp事件的句柄。

    Notification方法
    对应对象:Tcontrol
    声明:Toperation=(opInsert,opRemove);
    procedure Notification(Acomponent:Tcomponent;Operation:Toperation);override;
    功能:当弹出式菜单的参考被破坏时Notification方法允许Tcontrol更新它的弹出式菜单的属性。

    PaletteChanged方法
    对应对象:Tcontrol
    声明:function PaletteChanged(Foreground:Boolean):Boolean;dynamic;
    功能:PaletteChanged方法对系统调色板的改变进行反应,它重新设置控件调色板的大小。

    Perform方法
    对应对象:Tcontrol
    声明:function Perform(Msg:Cardinal;WParam,Lparam:Longint):Longint;
    功能:Perform方法当控件接受指定的系统信息时反应。

    Refresh方法
    对应对象:Tcontrol
    声明:procedure Refresh;
    功能:Refresh方法用来删除控件中的图像并且重新绘制控件。 Refresh方法使用了InValidate和Update以刷新控件。如果用户的显示部分和其它的分布相混合,可以使用该方法进行更新。
    例子:
    procedure Tform1.mnuRefreshClick(Sender:Tobject);
    begin
    Form1.Refresh;
    end;

    Repaint方法
    对应对象:Tcontrol
    声明:procedure Repaint;
    功能:Repaint方法使控件对自已进行重新绘制。Repaint方法和Refresh方法一样,只是这个方法不先删除控件的图像。如果用户希望首先删除控件之后再绘制它,可以使用Refresh方法。

    ScreenToClient方法
    对应对象:Tcontrol
    声明:Tpoint=record
    X:Longint;
    Y:Longint;
    End;
    Function ScreenToClient(const Point:Tpoint):Tpoint;
    功能:ScreenToClient方法将屏幕的坐标值转换成为控件的坐标值,ScreenToClient方法可以和屏幕到用户区的方法一起使用,以便将应该控件的坐标转换成为另一个控件的坐标值。

    SendCancelMode方法
    对应对象:Tcontrol
    声明:procedure SendCancelMode(Sender:Tcontrol);
    功能:SendCancelMode方法取消了控件的模式状态。

    SendToBack方法
    对应对象:Tcontrol
    声明:procedure SendToBack;
    功能:SendToBack方法将控件放置到容器中的所有其它控件的下面。窗口和非窗口控件有不同的Z轴的次序集合。一个窗体上的每一个窗口都在一个相同的Z轴的次序集合中,窗口控件总是出现在非窗口控件的上面,所以使用SendToBack方法将不能使一个非窗口控件上面的窗口控件放置到它的下面。
    例子:

    //Send the button behind the Panel
    procedure Tform1.Button1Click(Sender:Tobject);
    begin
    Button1.SendToBack;
    End;

    SetBounds方法
    对应对象:Tcontrol
    声明:procedure SetBounds(Aleft,Atop,Awidth,Aheight:Integer);virtual;
    功能:SetBounds方法用来设置控件的Left,Top,Width和Height属性。SetBounds方法使用用户可以在一次中设置控件边界的所有属性。这样可以使控件在一次重新绘制时就完成最后的效果,然而,一般的单独调用将使控件进行多次的重新绘制。
    例子:

       //Have the panel resize with the form
    procedure Tform1.FormResize(Sender:Tobject);
    begin
    Panel1.SetBounds(10,10,Form1.ClientWidth-20,Form1.ClientHeight-20);
    End;

    SetDragMode方法
    对应对象:Tcontrol
    声明:TdragMode=(dmManual,dmAutomatic);
    procedure SetDragMode(Value:TdragMode);virtual;
    功能:SetDragMode方法为控件设置了拖动的模式。

    SetName方法
    对应对象:Tcontrol
    声明:TcomponentName=type string;
    procedure SetName(const Value:TcomponentName);override;
    功能:SetName方法设置了控件的名。

    SetParent方法
    对应对象:Tcontrol
    声明:procedure SetParent(Aparent:TwinControl);virtual;
    功能:SetParent方法使控件可以设置它的父类。

    SetTextBuf方法
    对应对象:Tcontrol
    声明:procedure SetTextBuf(Buffer:Pchar);
    功能:SetTextBuf方法使一个缓冲区中的文字拷贝到一个控件中。
       Buffer是一个指向以空字符结束的字符串。
    例子:

       procedure Tform1.Button2Click(Sender:TObject);
    var MyBuffer:Pchar;
    MyBufSize:Integer;
    Begin
    MyBufSize:=Button1.GetTextLen;
    Button1.GetTextBuf(MyBuffer,MyBufSize);
    StatusBar1.SetTextBuf(MyBuffer);
    End;

    SetZOrder方法
    对应对象:Tcontrol
    声明:procedure SetZOrder(TopMost:Boolean);dynamic;
    声明:Trect=record
    case Integer of
    0:(Left,Top,Right,Bottom:Integer);
    1:(TopLeft,BottomRight:Tpoint);
    end;
    procedure UpdateBoundsRect(const R:Trect);
    功能:UpdateBoundsRect方法改变控件的Top,Left,Width和Height属性,但是没有更新控件的屏幕图像。

    OnClick事件
    对应对象:Tcontrol
    声明:TnotifyEvent=procedure(Sender:Tobject) of object;
    property:TnotifyEvent;
    功能:OnClick事件在鼠标指针点击控件时发生。
      当用户使用鼠标在控件上时点击鼠标按钮激发一个控件,或用户通过其它的操作触发OnClick事件。这个事件是应用程序使用最多的一个事件。用户可以为OnClick事件的处理程序设置为运行的过程,也可以在设计时,在大小探测器中为一个控件选择Onlick事件来完成操作。

    OnDblClick事件
    对应对象:Tcontrol
    声明:TnotifyEvent=procedure(Sender:Tobject) of object;
    property OnDblClick:TnotifyEvent;
    功能:OnDblClick事件当用户双击控件时发生。在用户在一个控件上双击鼠标时将引发OnDblClick事件。用户可以为一个OnDblClick事件的处理程序设置为一个运行过程,也可以在设计时,在大小探测器中为一个控件选择OnDblClick事件来完成操作。

    OnDragDrop事件
    对应对象:Tcontrol
    声明:TdragDropEvent=procedure(Sender,Source:Tobject;X,Y:Integer) of object;
    property OnDragDrop:TdragDropEvent;
    功能:OnDragDrop事件当一个被拖动的对象被放置到控件上时发生。Sender参数说明了将被放置对象的控件的标识符。Source参数说明了被拖动放置的对象。坐标参数说明了对象被放置到控件的位置。用户可以为一个OnDragDrop事件的处理程序设置为一个运行过程,也可以在设计时,在大小探测器中为一个控件选择OnDragDrop事件来完成操作。
    例子:

       type
    Tform1=class(Tform)
    Panel1:Tpanel;
    Image1:Timage;
    Procedure MyDragDrop(Sender,Source:Tobject;X,Y:Integer);
    Procedure MyDragOver(Sender,Source:Tobject;X,Y:Integer;State:TdragState;var Accept:Boolean);
    Private
    {Private declarations}
    Public
    {Public declarations}
    end;

    var
    Form1:Tform1;

    Implementation

    {$R *.DFM}

    procedure Tform1.MyDragDrop(Sender,Source:Tobject;X,Y:Integer);
    begin
    if Soruce is Timage then
    begin
    TImage(Source).Parent:=Panel1;
    TImage(Source).Left:=X;
    Timage(Source).Top:=Y;
    End;
    End;

    Procedure Tform1.MyDragOver(Sender,Source:Tobject;X,Y:Ingeger;State:TdragState; var Accept:Boolean);
    Begin
    if Soruce is Timage then begin
    Timage(Source).DragCursor:=crCross;
    Accept:=True;
    End;
    End;

    Procedure Tform1.FormCreate(Sender:Tobject);
    Begin
    Panel1.OnDragDrop:=Form1.MyDragDrop;
    Panel1.OnDragOver:=Form1.MyDragOver;
    End;

    OnDragOver事件
    对应对象:Tcontrol
    声明:TdragState=(dsDragEnter,dsDragLeave,dsDragMove);
    TdragOverEvent=procedure(Sender,Source:Tobject;X,Y:Integer;State:TdragState;var:Boolean) of object;
    功能:OnDragOver事件在一个控件上拖动对象时发生。

      当用户在控件上拖动一个对象时,OnDragOver事件将发生。Sender说明了控件的标识符。Soruce参数说明被拖动的对象。坐标参数说明了被拖动对象在控件坐标上的位置。Accept参数说明了控件是否允许被拖动的对象放置在它的上面。如果Accept参数被设置为真,那么将使控件接受对象的放置。否则不接受。用户可以为一个OnDragOver事件的处理程序设置为一个运行过程,也可以在设计时,在大小探测器中为一个控件选择OnDragOver事件来完成操作。
    例子:参见OnDragDrop事件的例子。

    OnEnddrag事件
    对应对象:Tcontrol
    声明:TendDragEvent=procedure(Sender,Target:Tobject;X,Y:Integer) of object;
    property OnEndDrag:TendDragEvent;
    功能:OnEndDrag事件在一个拖动的操作停止时发生。
      当控件接受一个被拖动的对象,或者用户取消了拖动操作时,用户可取消拖动操作。Sender参数是被拖动的对象。Target是鼠标对应的控件,当一个拖动的操作停止时,它将变为被拖动的对象。坐标是使用Target控件的坐标用来说明被拖动的对象在当前的位置。用户可以为一个OnEndDrag事件的处理程序设置一个运行过程,也可以在设计时,在大小探测器中为一个控件选择OnEndrag事件来完成操作。
    例子:

    type
    Tform1=class(Tform)
    Panel1:Tpanel;
    Image1:Timage;
    Procedure MyEndDrag(Sender,Target:Tobject;X,Y:Integer);
    Private
    {Private declarations}
    public
    {Public declarations}
    end;

    var
    Form1:tForm1;

    Implementation

    {$R *.DFM}

    procedure Tform1.FormCreate(Sender:Tobject);
    begin
    Image1.OnEndDrag:=Form1.MyEndDrag;
    End;

    Procedure Tform1.MyEndDrag(Sender,Target:Tobject;X,Y:Integer);
    Begin
    If Target is Tpanel then
    StatusBar1.Panels[1].text:=’Drag ended on panel.’
    Else
    Statusbar1.panels[1].text:=’Drag did not end on panel.’;
    End;

    OnMouseDown事件
    对应对象:Tcontrol
    声明:TMouseButton=(mbLeft,mbRight,mbMiddle);
    TshiftState=set of ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble);
    TMouseEvent=procedure(Sender:Tobject;Button:TmouseButton;Shift:Tshiftstat e;X,Y:Integer) of object;
    Property OnMouseDown:TmouseEvent;
    功能:OnMouseDown事件当在控件上点击鼠标时激发。
      Sender参数用来说明鼠标点击时,鼠标下面的那一个控件。Button参数说明了使用哪一个鼠标的按钮,此变量是属于TmouseButton类型,有效时为mbLeft,mbRight和mbMiddle。Shift参数是ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble这些参数的任意的组合,如果没有使用修正键,那么Shift将被设置成为[].坐标的参数使用了Sender控件坐标以指出点击时鼠标的位置。用户可以为一个OnMouseDown事件的处理程序设置一个运行过程,也可以设计时,在大小探测器中为一个控件选择OnMouseDown事件来完成操作。
    例子:

    type
    Tform1=class(Tform)
    Procedure MyMouseDown(Sender:Tobject;Button:TmouseButton:Shift;TshiftState;X,Y:Integer);
    Private
    {Private declarations}
    public
    {public declarations}
    end;

    var
    Form1:Tform1;

    Implementation

    {$R *.DFM}

    procedure Tform1.FormCreate(Sender:Tobject);
    begin
    Form1.MyMouseDown:=Form1.MyMouseDown;
    End;

    Procedure Tform1.MyMouseDown(Sender:Tobject;Button:TmouseButton;Shift:TSHiftState;X,Y:Integer);
    Begin
    StatusBar1.Panels[0].Text:=’MouseDown on Form:’+IntToStr(X)+’,’+IntToStr(Y);
    End;

    OnMouseMove事件
    对应对象:Tcontrol
    声明:TshiftState=set of(ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble);
    TmouseMoveEvent=procedre(Sender:Tobject;Shift:TshiftState;X,Y:Integer) of object;
    Property OnMouseMove:TmouseMoveEvent;
    功能:OnMouseMove事件当鼠标指针在控件上移动时发生。
      当鼠标指针通过每一个控件时,将连续地发生OnMouseMove事件。这个事件的发生将不需要鼠标的点击。Sender参数说明了发生事件的控件。Shift参数是ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble这些参数的任意的组合,如果没有使用修正键那么Shift将被设置成为[].在事件发生时坐标参数将使用控件的坐标系来说明鼠标的位置。用户可以为一个OnMouseMove事件的处理程序设置一个运行过程,也可以设计时,在大小探测器中为一个控件选择OnMouseMove事件来完成操作。
    例子:

    type
    Tform1=class(Tform)
    StatusBar1:TstatusBar;
    Procedure MyMouseMove(Sender:Tobject;Shift:TshiftState;X,Y:Integer);
    Private
    {private declarations}
    public
    {public declarations}
    end;

    var
    Form1:Tform1;

    Implementation

    {$R *.DFM}

    procedure Tform1.FormCreate(Sender:Tobject);
    begin
    Form1.OnMouseMove:=Form1.MyMouseMove;
    End;

    Procedure Tfrom1.MyMouseMove(Sender:Tobject;Shift:TshiftState;X,Y:Integer);
    Begin
    StatusBar1.Panels[2].Text:=’MouseMove on Form:’+IntToStr(X)+’,’+IntToStr(Y);
    End;

    OnMouseUp事件
    对应对象:Tcontrol
    声明:TmouseButton=(mbLeft,mbRight,mbMiddle);
    TshiftState=set of(ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble);
    TmouseEvent=procedure(Sender:Tobject;Button:TmouseButton;Shift:TshiftStatus;X,Y:Integer) of object;
    Property OnMouseUp:TmouseEvent;
    功能:OnMouseUp事件当用户点击一个鼠标的按钮时发生。在任何时候用户点击了按钮时,这个事件总是会发生。它说明了用户点击了哪一个按钮,在用户释放按钮时指明按钮指针的位置。Shift参数是ssShift,ssAlt,ssCtrl,ssLeft,ssRight,ssMiddle,ssDouble这些参数的任意组合,如果没有使用修正键那么Shift将被设置成为[]。Button参数说明了是用户释放的是哪一个按钮,它可以是mbLeft,mbRight,mbMiddle三个值:左按钮、右按钮、中间按钮。坐标参数说明了在释放鼠标按钮时,鼠标指针在控件坐标中的位置。用户可以为一个OnMouseUp事件的处理程序设置一个运行过程,也可以设计时,在大小探测器中为一个控件选择OnMouseUp事件来完成操作。
    例子:

       type
    Tform1=class(Tform)
    Procedure MyMouseUp(Sender:Tobject;Button:TmouseButton;Shift:TshiftState;X,Y:Integer);
    Private
    {private declarations}
    public
    {public declarations}
    end;

    var
    Form1:Tform1;

    Implementation

    {$R *.DFM}

    procedure Tform1.FormCreate(Sender:Tobject);
    begin
    Form1.OnMouseUp:=Form1.MyMouseUp;
    End;

    Procedure Tform1.MymouseUp(Sender:Tobject;Button:TmouseButton;Shift:TshiftState;X,Y:Integer);
    Begin
    StatusBar1.Panels[0].Text:=’MouseUp on Form:’+IntToStr(X)+’,’+IntToStr(Y);
    End;

    OnStartDrag事件
    对应对象:Tcontrol
    声明:TstartDragEvent=procedure (Sender:Tobject;var DragObject:TdragObject) of object;
    property OnStartDrag:TstartDragEvent;
    功能:OnStartDrag事件在控件释放操作发生时点发生。当用户在一个控件上放置鼠标并且点击了按钮以便对控件进行拖动时,OnStartDrag事件将被触发。DragObject参数说明了被拖动的目标。用户可以为一个OnStartDrag事件的处理程序设置一个运行过程,也可以设计时,在大小探测器中为一个控件选择OnStartDrag事件来完成操作。
    例子:

    type
    Tform1=class(Tform)
    StatusBar1:Tstatusbar;
    Procedure MyStartDrag(Sender:Tobject;var DragObject:TdragObject);
    Private
    {private decalrations}
    public
    {public declarations}
    end;

    var
    Form1:Tform1;

    Implementation

    {$R *.DFM}

    procedure Tform1.FormCreate(Sender:Tobject);
    begin
    Image1.OnStartDrag:=Form1.MyStartDrag;
    End;

    Procedure Tform1.MyStartDrag(Sender:Tobject;var DragObject:TdragObject);
    Begin
    StatusBar1.Panels[1].Text:=’Drag Started.’;
    End;


    2003-11-14 15:50:26 VCL组件的属性和方法详解 -- 五、Tscreen 五、Tscreen
    Tobject—>TPersistent—>Tcomponent
    Tscreen的属性:

    In Tscreen
    ActiveControl
    ActiveCustomForm
    ActiveForm
    Cursor
    Cursors
    CustomFormCount
    CustomForms
    DataModuleCount
    DataModeles
    DefaultIme
    DefaultKbLayout
    Fonts
    FormCount
    Forms
    Height
    IconFont
    Imes
    PixelsPerInch
    Width

    从Tcomponent继承来的:
    ComObject
    ComponentCount
    ComponentIndex
    Components
    ComponentState
    ComponentStyle
    DesignInfo
    Name
    Owner
    Tag
    VCLComObject

    TScreen的方法
    In TScreen
    Create
    Destroy

    从TComponent继承来的:
    DestroyComponents
    Destroying
    FindComponent
    FreeNotification
    FreeOnRelease
    GetParentComponent
    HasParent
    InsertComponent
    RemoveComponent
    SafeCallExecption

    从TPersistent继承来的:
    Assign
    GetNamePath

    从TObject继承来的:
    ClassInfo
    ClassName
    ClassNameIs
    ClassParent
    ClassType
    CleanupInstance
    DefaultHandler
    Dispatch
    FieldAddress
    Free
    FreeInstance
    GetInterface
    GetInterfaceEntry
    GetInterfaceTable
    InheritsFrom
    InitInstance
    InstanceSize
    MethodAddress
    MethodName
    NewInstance

    TScreen的事件:
    In TScreen
    OnActiveControlChange
    OnActiveFormChange

    ActiveControl属性
    对应对象:TScreen
    声明:property ActiveControl :TWinControl;
    功能:ActiveControl属性用来确定有焦点的控件。
    在任何时候,整个屏幕上只有一个控件有焦点。如果控件在应用程序的外面,则用户不能访问它。一般ActiveControl被限制在应用程序的内部。
    例子:

    //Create a form with many controls,change the Interval property
    //of the Timer to 500-every time a control is selected,the Form
    //Caption changes to indicate which control has the foucus
    procedure TForml.TimerlTimer(Sender:TObject);
    begin
    Form1.Caption := Screen.ActiveControl.Name;
    end;

    ActiveForm属性
    对应对象:TScreen
    声明:property ActiveForm :TForm;
    功能:ActiveForm属性用来确定被激活的窗体是哪一个窗体。这个属性是只读型的。它指出具有焦点的窗体。
    例子:

    //Create a program with two forms-Show Form2 by
    //clicking a button on the first form. This method will
    //put the name of the active form on Form2’s caption
    procedure TForm2.Timer1Timer(Sender : TObject);
    begin
    Form2.Caption := Screen.ActiveForm.Name;
    end;

    Cursor属性
    对应对象:TScreen
    声明: property Cursor:TCursor;
    功能:Cursor属性用来确定光标的形状。
    改变Cursor属性的值将对应地改变应用程序中用户区域的光标形状。
    以下说明使用的TCursor类型时的可能值:

    类型常数 / 值 / 功 能

    crDefautl / 0 依据ActiveControl。

    crNone / -1/ 无光标。

    crArrow / -2 / 标准光标。

    crCross / -3 / 十字光标。

    crIBeam / -4 / I形光标。

    crSize / -5 / 十字箭头光标。

    crSizeNESW / -6 / 右斜方箭头光标。

    crSizeNS / -7 / 上下方箭头光标。

    crSizeNWSE / -8 / 左斜方箭头光标。

    crSizeWE / -9 / 左右箭头光标。

    crUpArrow / -10 / 向上箭头光标。

    crHourGlass / -11 / 等待光标。

    crDrag / -12 / 箭头加文本光标。

    crNoDrop / -13 /

    crHSPlit / -14 / 左右移动表格线光标。

    crVSplit / -15 / 上下移动表格线光标。

    crMultiDrag / -16 / 箭头加多文本光标。

    crSQLWait / -17 / SQL加等待光标。

    crNo / -18 /

    crAppStart / -19 / 等待加箭头光标。

    crHelp / -20 / 箭头加问号光标。

    crHandPoint / -21 / 手光标。

    例子:
    procedure TForm1.FormCreate(Sender : TObject);
    begin
    Screen.Cursor := crUpArrow;
    end;

    Cursors属性
    对应对象:TScreen
    声明:property Cursors [Index:Integer] : HCursor;
    功能:Cursors属性是用户可以使用的光标数组。
    Cursors属性允许用户在应用程序中加载自定义的光标,全局光标的预定义集由TCursor来定义。前面介绍的Cursor属性中说明了TCursor类的光标元素。如果用户希望创建自己的光标,可以使用Delphi的图形编辑器来绘制光标,并且在源代码中说明一个常量来表示光标在Cursors数组中的位置,使用系统的API函数比LoadCursor以便使这个光标成为程序共享的资源。例如,设想一个用户定制的光标已经被加载到应用程序的资源中去,并且命名为NewCursor。以下的代码使这个光标在应用程序中是有效的,通过光标常数crMyCursor,并设置它是全局的。
    例子:

    implementation

    {$R *.DFM}

    const
    crMyCursor = 5;

    procedure TForm1.FormCreate(Sender : TObject);
    begin
    Screen.Cursors[crMyCursor] := LoadCursor(HInstance, ‘NewCursor’);
    Cursor := crMyCursor;
    end;

    CustomFormCount属性
    对应对象:TScreen
    声明:property CustomFormCount : Integer;
    功能:CustomFormCount说明了在屏幕上所显示的窗体号或属性页。

    CustomForms属性
    对应对象:TScreen
    声明:property CustomForms [Index :Integer]:TCustomForm;
    功能:CustomForms是一个所有的属性页和窗体的例表,它们是在当前的屏幕上显示。

    DataModuleCount属性
    对应对象:TScreen
    声明:property DataModuleCount:Integer;
    功能:DataModuleCount属性说明了在当前的应用程序中例示的数据模块的号。

    DataModules属性
    对应对象:TScreen
    声明:property DataModules [Index:Integer]:TDataModule;
    功能:DataModules是在当前应用程序中例示的所有数据模块的例表数组。

    DefaultIme属性
    对应对象:TScreen
    声明:property DefaultIme:string;
    功能:DefaultIme属性说明了输入方法编辑器的名,输入方法编辑器在TScreen对象被创建时被激活。

    DefauItKbLayout属性
    对应对象:TScreen
    声明:property DefaultKbLayout:HKL;
    功能:DefauItKbLayout属性是当应用程序开始运行时被激活的键盘版面所对应的窗口句柄。

    Fonts属性
    对应对象:TScreen
    声明:property Fonts:TStrings;
    功能:Fonts属性说明了包含在应用程序中可用的字体例表。Fonts属性是只读型的,它包含了屏幕支持的字体例表,应用程序可用访问。用户可以使用Fonts属性来确定某种字体是否可以被使用,进而确定所使用的字体。
    例子:

    //Display all of the available fonts
    procedure TForm1.FormCreate(Sender : TObject);
    begin
    ListBox1.Sorted := True;
    ListBox1.Items := Screen.Fonts;
    end;

    FormCount属性
    对应对象:TScreen
    声明:property FormCount:Integer;
    功能:FormCount属性包含了应用程序中屏幕上可以看到的窗体数目。它是只读型的。
    例子:

    //Get form count
    procedure TForm1.Button1Click(Sender : TObject);
    begin
    Label1.Caption := ‘There is/are’ + IntToStr(Screen.FormCount) +
    ‘form(s) on the screen.’;
    end;

    Forms属性
    对应对象:TScreen
    声明:property Forms[Index:Integer] : TFonn;
    功能:Forms属性对应了显示的窗体数组。在应用程序中的每一个窗体所对应的Forms数组中都给了一个确定的位置。程序创建的第一个窗体是Forms[0],第二个窗体是Forms[1],依此类推。Forms允许用户通过Index值访问应用程序的每—个窗体。
    例子:
    当按钮1被按击时,以下的代码加载了在屏幕上的所有的窗体名到ListBoxl上。

    procedure TForm1.Button1Click(Sender : TObject);
    var
    I : integer;
    begin
    For I := 0 to Screen.FormCount – 1 do
    ListBox1.Items.Add(Screen.Forms[I ].Name);
    end;

    Height属性
    对应对象:TScreen
    声明:property Height : Integer;
    功能:Height属性包含有屏幕的高度。
    Height属性是只读型的,包含有屏幕的垂直高度尺寸,并以象素来计数。
    例子:

    procedure TfrmScreenInfo.FormCreate(Sender : TObject);
    begin
    lblWidth.Caption := IntToStr(Screen.Width);
    lblHeight.Caption := IntToStr(Screen.Height);
    lblPixelsPerInch.Caption := IntToStr(Screen.PixelsPerInch);
    end;

    IconFont属性
    对应对象:TScreen
    声明:property IconFont : TFone;
    功能:IconFont属性是说明了在文件选择对话框中,显示在图标上的标签的字体形式。

    Imes属性
    对应对象:TScreen
    声明:property Imes : TStrings;
    功能:Imes属性说明了在系统上安装的所有输入方法编辑器的例表。

    Width属性
    对应对象:TScreen
    声明:property Width:Integer;
    功能:Width属性说明了屏幕的宽度。这个属性是只读型的,包含有屏幕的水平尺寸,以象素来计数。示例:

    with Screen do
    for I := 0 to FormCount – 1 do
    if Forms[I].Width > Width then Forms[I].Width := Width;

    Create方法
    对应对象:TScreen
    声明:constructor Create(AOwner:TComponent);override;
    功能:Create方法用来创建一个TScreen对象的实例。

    Destroy方法
    对应对象:TScreen
    声明:destructor Destroy;override;
    功能:Destroy方法用来消除一个TScreen对象的实例。

    OnActiveControlChange事件
    对应对象:TScreen
    声明:TNotifyEvent = procedure(Sender :TObject)of object;
    property OnActiveControlChange:TNotifyEvent;
    功能:当屏幕的焦点从一个控件转换到另一个控件时发生OnActiveControlChange事件。如果每一次焦点的转换事件发生时用户希望应用程序处理一些操作的话,可以对OnActiveControlChange事件创建一个事件的处理代码来完成。当OnActiveCon-trolChange事件发生时,屏幕的激活控制属性的值将成为将要接收焦点的控件的属性值。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, ExtCtrls;

    Type
    TForm1 = class(TForm)
    RadioGroup1 : TRadioGroup;
    RadioButton1 : TRadioButton;
    RadioButton2 : TRadioButton;
    RadioButton3 : TRadioButton;
    CheckBox1 : TCheckBox;
    CheckBox2 : TCheckBox;
    Button1 : TButton;
    Button2 : TButton;
    Procedure FormCreate(Sender : TObject);
    private
    {Private declarations}
    public
    //Manually added method declaration
    Procedure FocusChanged(Sender : TObject);
    end;

    var
    Form1 : TForm1;

    implementation

    {$R *.DFM}

    //Create an event handler for OnActiveControlChange
    procedure TForm1.FormCreate(Sender : TObject);
    begin
    Screen.OnActiveControlChange := FocusChanged;
    end;

    //Respond to OnActiveControlChange events
    procedure TForm1.FocusChanged(Sender : TObject);
    begin
    if Screen.ActiveControl = Button2 then
    Button1.Enabled := False;
    Else Button1.Enabled := True;
    end;

    end.

    OnActiveFormChange事件
    对应对象:TScreen
    声明:TNotifyEvent = procedure(Sender:TObject) of object;
    property OnActiveFormChange:TNotifyEvent;
    功能:在激活的窗体被改变之前OnActiveFormChange事件发生。用户可以为OnActiveFormChange事件创建一个认为代码来实现在窗体改变之前希望完成的操作。
    例子:

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    StdCtrls, ExtCtrls;

    Type
    TForm1 = class(TForm)
    RadioGroup1 : TRadioGroup;
    RadioButton1 : TRadioButton;
    RadioButton2 : TRadioButton;
    RadioButton3 : TRadioButton;
    CheckBox1 : TCheckBox;
    CheckBox2 : TCheckBox;
    Button1 : TButton;
    Button2 : TButton;
    Label1 : TLabel;
    procedure FormCreate(Sender : TObject);
    procedure Button1Click(Sender : TObject);
    private
    {Private declarations}
    public
    //Manually added method declaration
    Procedure FormChanged(Sender : TObject);
    end;

    var
    Form1 : TForm1;

    implementation

    uses Unit2;

    {$R *.DFM}

    //Create an event handler for OnActiveFormChange
    procedure TForm1.FormCreate(Sender : TObject);
    begin
    Screen.OnActiveFormChange := FormChanged;
    end;

    //Handle the OnActiveFormChange event
    procedure TForm1.FocusChanged(Sender : TObject);
    begin
    Label1.Caption := ‘Active Form is’ + Screen.ActiveForm.Name;
    end;

    //Show Form2 when the button is pressed
    procedure TForm1.Button1Click(Sender : TObject);
    begin
    Form2.Show;
    end;

    end.

    (出处:www.delphibbs.com)

    郑重声明:此文章由网友发布,仅供学习参考!如有侵权,请及时告知我们将之移除!

    http://www.delphifans.com/Search_Article.asp 高级搜索

  • 相关阅读:
    [学习记录]Flask会话维护
    [学习记录]MarkDown语法
    [学习记录]jinja2模板语法
    [学习记录]flask资源加载
    [学习记录]flask初步
    [常用操作]使用github桌面版上传代码
    [学习记录]简明扼要的Sass
    接口Mock测试
    12 | 从0到1:你的第一个GUI自动化测试
    navicat导出DDL语句
  • 原文地址:https://www.cnblogs.com/chulia20002001/p/1826687.html
Copyright © 2020-2023  润新知