Delphi tscreen class

Source: Internet
Author: User

 

 

Tscreen class-get the font list
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) memo1: tmemo; Procedure formcreate (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.formcreate (Sender: tobject); begin align: = ssboth; memo1.align: = alleft; memo1.clear; {retrieve the font list by using only one sentence through the screen object} memo1.lines: = screen. fonts; end.
  

Tscreen-logic width and height of the screen
VaR W, H: integer; begin W: = screen. width; H: = screen. height; text: = format ('the resolution of the current screen is % d * % d', [W, H]); end;

Tscreen-Screen Object

The screen object is a variable of the tscreen class and is declared in the 1,323rd rows (Delphi 2007) of the forms unit );
The tscreen class also comes from forms units.
That is to say, the screen object can be used as long as the uses forms unit is used.

Can we create a tscreen class object by ourselves? Of course!

VaR myscreen: tscreen; begin myscreen: = tscreen. create (NiL); {create} showmessage (inttostr (myscreen. width); {display: 1024; my screen resolution is 1024*768} myscreen. free; {release} myscreen: = nil; {root disconnection} end;

Tscreen-number of forms in the program
// An example containing two forms: Program project1; uses forms, unit1 in 'unit1. PAS '{form1}, unit2 in 'unit2. PAS '{form2}; {$ R *. res} begin application. initialize; application. mainformontaskbar: = true; application. createform (tform1, form1); application. createform (tform2, form2); application. run; end.
     // Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses unit2; Procedure tform1.button1click (Sender: tobject); var num: integer; begin num: = screen. formcount; {number of forms in the current program} showmessage (inttostr (Num); {2} screen. forms [1]. showmodal; {display the second form} {the above sentence is equivalent to} // form2.showmodal; end.

Tscreen-use screen to change the cursor
// Changing the form or the cursor of a widget may not pass the screen object, for example, begin self. cursor: = crappstart; panel1.cursor: = crhandpoint; {optional cursor values: crdefault = tcursor (0); crnone = tcursor (-1); crarrow = tcursor (-2 ); crcross = tcursor (-3); cribeam = tcursor (-4); crsize = tcursor (-22); crsizenesw = tcursor (-6); crsizens = tcursor (-7 ); crsizenwse = tcursor (-8); crsizewe = tcursor (-9); cruparrow = tcursor (-10); crhourglass = tcursor (-11); crdrag = tcursor (-12 ); crnodrop = tcursor (-13); crheatmap = tcursor (-14); crvsplit = tcursor (-15); crmultidrag = tcursor (-16); crsqlwait = tcursor (-17 ); crno = tcursor (-18); crappstart = tcursor (-19); crhelp = tcursor (-20); crhandpoint = tcursor (-21 ); crsizeall = tcursor (-22);} // Where crdefault is the default cursor end;
      // Use screen to change the cursor. This is to change the cursor globally for the program, for example, begin screen. cursor: = crsize; end;
      // If the control has a different cursor, screen. cursor must be the default value, that is, screen. cursor: = crdefault;

Tscreen class-controls/Windows that determine the current focus
Procedure tform1.timer1timer (Sender: tobject); begin text: = screen. activecontrol. classname; end; {put more controls and test by tab; but not all controls have focus}


// The title displays the class name procedure tform1.timer1timer (Sender: tobject); begin text: = screen. activeform. classname; end;

Tscreen class-get the current input method and Input Method list
// Obtain the input method list begin memo1.lines: = screen. imes; end;
        // Obtain the current input method var KL: HKL; I: integer; begin KL: = getkeyboardlayout (0); for I: = 0 to screen. imes. count-1 do if HKL (screen. imes. objects [I]) = KL then showmessage (screen. imes. strings [I]); {display current input method} end;

 


 




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.