VCL组件的属性和方法详解(3)

Invalildate 方法 对应对象:TControl声明:procedure Invalidate;virtual;功能:Invalidate方法使控件对本身进行再次绘制。在调用Invalidate方法时应该尽快地重新绘制控件,Invalidate方法有Refresh调用。例子:procedure Tform1.Button1Click(Sender:Tobject);begin//Invalidate the form so that it can be repaintedForm1.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—>TcomponentTscreen的属性:In TscreenActiveControlActiveCustomFormActiveFormCursorCursorsCustomFormCountCustomFormsDataModuleCountDataModelesDefaultImeDefaultKbLayoutFontsFormCountFormsHeightIconFontImesPixelsPerInchWidth从Tcomponent继承来的:ComObjectComponentCountComponentIndexComponentsComponentStateComponentStyleDesignInfoNameOwnerTagVCLComObjectTScreen的方法In TScreenCreateDestroy从TComponent继承来的:DestroyComponentsDestroyingFindComponentFreeNotificationFreeOnReleaseGetParentComponentHasParentInsertComponentRemoveComponentSafeCallExecption从TPersistent继承来的:AssignGetNamePath从TObject继承来的:ClassInfoClassNameClassNameIsClassParentClassTypeCleanupInstanceDefaultHandlerDispatchFieldAddressFreeFreeInstanceGetInterfaceGetInterfaceEntryGetInterfaceTableInheritsFromInitInstanceInstanceSizeMethodAddressMethodNameNewInstanceTScreen的事件:In TScreenOnActiveControlChangeOnActiveFormChangeActiveControl属性对应对象: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 foucusprocedure TForml.TimerlTimer(Sender:TObject);beginForm1.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 captionprocedure TForm2.Timer1Timer(Sender : TObject);beginForm2.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);beginScreen.Cursor := crUpArrow;end; Cursors属性 对应对象:TScreen声明:property Cursors [Index:Integer] : HCursor;功能:Cursors属性是用户可以使用的光标数组。Cursors属性允许用户在应用程序中加载自定义的光标,全局光标的预定义集由TCursor来定义。前面介绍的Cursor属性中说明了TCursor类的光标元素。如果用户希望创建自己的光标,可以使用Delphi的图形编辑器来绘制光标,并且在源代码中说明一个常量来表示光标在Cursors数组中的位置,使用系统的API函数比LoadCursor以便使这个光标成为程序共享的资源。例如,设想一个用户定制的光标已经被加载到应用程序的资源中去,并且命名为NewCursor。以下的代码使这个光标在应用程序中是有效的,通过光标常数crMyCursor,并设置它是全局的。例子:implementation{$R *.DFM}constcrMyCursor = 5;procedure TForm1.FormCreate(Sender : TObject);beginScreen.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 fontsprocedure TForm1.FormCreate(Sender : TObject);beginListBox1.Sorted := True;ListBox1.Items := Screen.Fonts;end; FormCount属性 对应对象:TScreen声明:property FormCount:Integer;功能:FormCount属性包含了应用程序中屏幕上可以看到的窗体数目。它是只读型的。例子://Get form countprocedure TForm1.Button1Click(Sender : TObject);beginLabel1.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);varI : integer;beginFor I := 0 to Screen.FormCount – 1 doListBox1.Items.Add(Screen.Forms[I ].Name);end; Height属性 对应对象:TScreen声明:property Height : Integer;功能:Height属性包含有屏幕的高度。Height属性是只读型的,包含有屏幕的垂直高度尺寸,并以象素来计数。例子:procedure TfrmScreenInfo.FormCreate(Sender : TObject);beginlblWidth.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 dofor I := 0 to FormCount – 1 doif 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 usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, ExtCtrls;TypeTForm1 = 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 declarationProcedure FocusChanged(Sender : TObject);end;varForm1 : TForm1;implementation{$R *.DFM}//Create an event handler for OnActiveControlChangeprocedure TForm1.FormCreate(Sender : TObject);beginScreen.OnActiveControlChange := FocusChanged;end;//Respond to OnActiveControlChange eventsprocedure TForm1.FocusChanged(Sender : TObject);beginif Screen.ActiveControl = Button2 thenButton1.Enabled := False;Else Button1.Enabled := True;end;end. OnActiveFormChange事件 对应对象:TScreen声明:TNotifyEvent = procedure(Sender:TObject) of object;property OnActiveFormChange:TNotifyEvent;功能:在激活的窗体被改变之前OnActiveFormChange事件发生。用户可以为OnActiveFormChange事件创建一个认为代码来实现在窗体改变之前希望完成的操作。例子:unit Unit1;interface usesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,StdCtrls, ExtCtrls;TypeTForm1 = 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 declarationProcedure FormChanged(Sender : TObject);end;varForm1 : TForm1;implementationuses Unit2;{$R *.DFM}//Create an event handler for OnActiveFormChangeprocedure TForm1.FormCreate(Sender : TObject);beginScreen.OnActiveFormChange := FormChanged;end;//Handle the OnActiveFormChange eventprocedure TForm1.FocusChanged(Sender : TObject);beginLabel1.Caption := ‘Active Form is’ + Screen.ActiveForm.Name;end;//Show Form2 when the button is pressedprocedure TForm1.Button1Click(Sender : TObject);beginForm2.Show;end;end.

你可能感兴趣的:(object,Integer,Class,button,fonts,Forms)