TApplication details 5-Tscreen

Source: Internet
Author: User

V. Tscreen

Tobject-> TPersistent-> Tcomponent

Tscreen attributes: inherited from TComponent:
In Tscreen DestroyComponents
ActiveControl FindComponent
ActiveCustomForm FreeNotification
ActiveForm FreeOnRelease
Cursor GetParentComponent
Cursors HasParent
CustomFormCount InsertComponent
CustomForms RemoveComponent
DataModuleCount SafeCallExecption
DataModeles inherited from TPersistent:
DefaultIme Assign
Defaultkblyout GetNamePath
Fonts inherited from TObject:
FormCount ClassInfo
Forms ClassName
Height ClassNameIs
IconFont ClassParent
Imes ClassType
PixelsPerInch CleanupInstance
Width DefaultHandler
Inherited from Tcomponent: Dispatch
ComObject FieldAddress
ComponentCount Free
ComponentIndex FreeInstance
Components GetInterface
ComponentState GetInterfaceEntry
ComponentStyle GetInterfaceTable
DesignInfo InheritsFrom
Name InitInstance
Owner InstanceSize
Tag MethodAddress
VCLComObject MethodName
NewInstance
TScreen method TScreen event:
In TScreen
Create OnActiveControlChange
Destroy OnActiveFormChange

 

 

ActiveControl attributes
Corresponding object: TScreen
Declaration: property ActiveControl: TWinControl;
Function: The ActiveControl attribute is used to determine controls with focus.
At any time, only one control on the screen has focus. If the control is outside the application, the user cannot access it. Generally, ActiveControl is restricted within the application.

Example:
// Create a form with your 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 attributes
Corresponding object: TScreen
Declaration: property ActiveForm: TForm;
Function: The ActiveForm attribute is used to determine which form is activated. This attribute is read-only. It indicates a form with focus.

Example:
// Create a program with two forms-Show Form2
// 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 attributes
Corresponding object: TScreen
Declaration: property Cursor: TCursor;
Function: The Cursor attribute is used to determine the shape of the Cursor.
Changing the value of the Cursor attribute will change the Cursor shape of the user area in the application.
The following describes the possible values of the TCursor type:

Type constant value power
CrDefautl 0 is based on ActiveControl.
CrNone-1: No cursor.
CrArrow-2 standard cursor.
CrCross-3 cross cursor.
CrIBeam-4 I-shaped cursor.
CrSize-5 cross arrow cursor.
CrSizeNESW-6 Right oblique arrow cursor.
CrSizeNS-7 Up and down arrow cursor.
CrSizeNWSE-8 left oblique arrow cursor.
CrSizeWE-9 arrow cursor.
CrUpArrow-10 up arrow cursor.
CrHourGlass-11: Wait for the cursor.
CrDrag-12 arrows and text cursor.
CrNoDrop-13
Move the table line cursor around-14.
CrVSplit-15 move the table line cursor up and down.
The crMultiDrag-16 arrow adds a multi-text cursor.
CrSQLWait-17 SQL + wait cursor.
CrNo-18
CrAppStart-19 wait for the arrow to cursor.
CrHelp-20 arrows and question mark cursor.
CrHandPoint-21 hand cursor.

Example:
Procedure TForm1.FormCreate (Sender: TObject );
Begin
Screen. Cursor: = crUpArrow;
End;

Cursors attributes
Corresponding object: TScreen
Declaration: property Cursors [Index: Integer]: HCursor;
Function: The Cursors attribute is an array of Cursors that you can use.
The Cursors attribute allows you to load a custom cursor in an application. The predefined set of the global cursor is defined by TCursor. The Cursor attribute described above describes the Cursor elements of the TCursor class. If you want to create your own cursor, you can use the Delphi graphic editor to draw the cursor and describe a constant in the source code to indicate the cursor position in the Cursors array, use the system's API functions than LoadCursor to make the cursor a resource shared by the program. For example, assume that a custom cursor has been loaded into the application resources and named NewCursor. The following code makes the cursor valid in the application. Use the crMyCursor constant of the cursor and set it to global.

Example:
Implementation
{$ R *. DFM}
Const
CrMyCursor = 5;
Procedure TForm1.FormCreate (Sender: TObject );
Begin
Screen. Cursors [crMyCursor]: = LoadCursor (HInstance, 'newcursor ');
Cursor: = crMyCursor;
End;

CustomFormCount attributes
Corresponding object: TScreen
Declaration: property CustomFormCount: Integer;
Function: mformcount indicates the form number or attribute page displayed on the screen.

CustomForms attributes
Corresponding object: TScreen
Declaration: property CustomForms [Index: Integer]: TCustomForm;
Function: mmforms is an example table of all attribute pages and forms, which is displayed on the current screen.

DataModuleCount attributes
Corresponding object: TScreen
Declaration: property DataModuleCount: Integer;
Function: The DataModuleCount attribute specifies the number of the data module as shown in the current application.

DataModules attributes
Corresponding object: TScreen
Declaration: property DataModules [Index: Integer]: TDataModule;
Function: DataModules is an array of example tables for all data modules as shown in the current application.

DefaultIme attribute
Corresponding object: TScreen
Declaration: property DefaultIme: string;
Function: The DefaultIme attribute specifies the name of the Input Method Editor. The input method editor is activated when the TScreen object is created.

Defauitkblyout attributes
Corresponding object: TScreen
Declaration: property defaultkblyout: HKL;
Function: The defauitkblyout attribute is the window handle corresponding to the keyboard layout activated when the application starts running.

Fonts attributes
Corresponding object: TScreen
Declaration: property Fonts: TStrings;
Function: The Fonts attribute describes the Fonts available in the application. The Fonts attribute is read-only and contains the font example table supported by the screen, which can be accessed by applications. You can use the Fonts attribute to determine whether a font can be used, and then determine the font used.

Example:
// Display all of the available fonts
Procedure TForm1.FormCreate (Sender: TObject );
Begin
ListBox1.Sorted: = True;
ListBox1.Items: = Screen. Fonts;
End;

 

FormCount attributes
Corresponding object: TScreen
Declaration: property FormCount: Integer;
Function: The FormCount attribute contains the number of forms displayed on the application screen. It is read-only.

Example:
// Get form count
Procedure TForm1.Button1Click (Sender: TObject );
Begin
Label1.Caption: = 'there is/are '+ IntToStr (Screen. FormCount) +
'Form (s) on the screen .';
End;

Forms attributes
Corresponding object: TScreen
Declaration: property Forms [Index: Integer]: TFonn;
Function: The Forms attribute corresponds to the displayed form array. A definite position is given in the Forms array corresponding to each form in the application. The first form created by the program is Forms [0], the second form is Forms [1], and so on. Forms allows you to access each form of an application using the Index value.

Example:
When button 1 is pressed, the following code loads all form names on the screen to 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 attribute
Corresponding object: TScreen
Declaration: property Height: Integer;
Function: The Height attribute contains the screen Height.
The Height attribute is read-only and contains the vertical Height of the screen and is measured in pixels.

Example:
Procedure TfrmScreenInfo. FormCreate (Sender: TObject );
Begin
LblWidth. Caption: = IntToStr (Screen. Width );
LblHeight. Caption: = IntToStr (Screen. Height );
LblPixelsPerInch. Caption: = IntToStr (Screen. PixelsPerInch );
End;

IconFont attributes
Corresponding object: TScreen
Declaration: property IconFont: TFone;
Function: The IconFont attribute indicates the font of the label displayed on the icon in the file selection dialog box.

Imes attributes
Corresponding object: TScreen
Declaration: property Imes: TStrings;
Function: The Imes attribute describes the example tables of all Input Method Editors installed on the system.

Width attribute
Corresponding object: TScreen
Declaration: property Width: Integer;
Function: The Width attribute specifies the screen Width. This attribute is read-only and contains the horizontal size of the screen, measured in pixels. Example:
With Screen do
For I: = 0 to FormCount-1 do
If Forms [I]. Width> Width then Forms [I]. Width: = Width;

Create method
Corresponding object: TScreen
Declaration: constructor Create (AOwner: TComponent); override;
Function: Create method is used to Create an instance of a TScreen object.

Destroy Method
Corresponding object: TScreen
Declaration: destructor Destroy; override;
Function: The Destroy method is used to remove an instance of a TScreen object.

OnActiveControlChange event
Corresponding object: TScreen
Declaration: tpolicyevent = procedure (Sender: TObject) of object;
Property OnActiveControlChange: tpolicyevent;
Function: The OnActiveControlChange event occurs when the screen focus is switched from one control to another. If you want the application to handle some operations when a focus conversion event occurs, you can create an event processing code for the OnActiveControlChange event. When the OnActiveCon-trolChange event occurs, the value of the Activation Control attribute of the screen will become the property value of the control that will receive focus.

Example:
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 event
Corresponding object: TScreen
Declaration: tpolicyevent = procedure (Sender: TObject) of object;
Property OnActiveFormChange: tpolicyevent;
Function: The OnActiveFormChange event occurs before the activated form is changed. You can create an operation for the OnActiveFormChange event that you want to complete before the form changes.

Example:
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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.