C++ Builder: TApplication and TScreenEach GUI application automatically declares a global Application variable, of the type TApplication. There is also a global Screen variable, of type TScreen, with information about the current screen device. TApplicationTApplication does not appear on the Component palette, nor is it available in the form designer to visually manipulate. Some properties of Application can be reached programmatically, or at design time in the pages "Application" and "Forms" of the Project / Options dialog box. Some properties of the Application object: ExeName is a read-only property that gives the name of the executable file. ExeName is the fully-qualified name, including the path to the application's executable. Title contains the text that appears below the icon representing the application when it is minimized. MainForm is the form that is the application's main window. The main form
is the first form created in the application. When the main form closes, the application terminates. Some methods of Application: MessageBox(Text, Caption, Flags) displays a dialog box containing
a message and one or more buttons. The parameters Caption and Flags are optional. ProcessMessages interrupts the execution of an application, cycles
the Windows message loop until it is empty, and then returns control to the application. Terminate ends the application execution. By calling Terminate, you shut down the application in an orderly fashion. In some cases Terminate is called automatically, such as when the main form closes. TScreenThe global variable Screen lets you obtain information about the current state of the screen in an application. Some properties of the Screen object: Cursor controls the mouse cursor image on a global level.
Cursor can be set to any of the cursor values available. This can be one of the built-in cursor values, or a custom
cursor that has been added to the Cursors property. The global mouse cursor image remains in effect
until the Cursor is changed back to crDefault. DesktopHeight gives the height of the desktop. The desktop is defined as the entire virtual desktop, which includes all monitors in the system. On a single-monitor system, DesktopHeight corresponds to Height. DesktopWidth gives the width of the desktop. The desktop is defined as the entire virtual desktop, which includes all monitors in the system. On a single-monitor system, DesktopWidth corresponds to Width. Fonts lists the names of the screen fonts that are currently installed. Applications can use Fonts to ensure that they do not request a font that is not installed on the user's system. When an application tries to use a font that is not installed, the system substitutes another font, which may not be appropriate to the application. PixelsPerInch gives the number of screen pixels that make up a logical inch in the vertical direction. PixelsPerInch is only accurate for vertical measurements. Most screens have a different scaling factor for horizontal measurements. Code examplesPath and name of the application's .exe file
Simple message box
Message box with a question
Screen Cursor and ProcessMessages
Selecting a font void __fastcall TForm1::FormCreate(TObject *Sender) { ComboBox1->Items = Screen->Fonts; } |