TApplication: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TApplication
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **TApplication** (with instance Application) that is available in every Lazarus program. | |
| 2 | + | ||
| 3 | + | Unlike [[TForm|forms]], and components on the forms a (single) instance of TApplication is created before any user line of code. In a .lpr file (a pascal file containing the [[Reserved words|keyword]] '[[Program|program]]' ) the Application-variable is used to create the applications form(s): | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | program pMyTest; | |
| 7 | + | uses | |
| 8 | + | Forms, uMyForm; | |
| 9 | + | ||
| 10 | + | {$R *.res} | |
| 11 | + | ||
| 12 | + | begin | |
| 13 | + | Application.Initialize(); | |
| 14 | + | Application.CreateForm( TMyForm, MyForm ); | |
| 15 | + | Application.Run(); | |
| 16 | + | end. | |
| 17 | + | ``` | |
| 18 | + | ||
| 19 | + | `TMyForm` is assumed a descendant of [[TForm]] and defined in `uMyForm.pas` | |
| 20 | + | ||
| 21 | + | ## Properties | |
| 22 | + | ||
| 23 | + | | Property | type | Writable | Description | | |
| 24 | + | |----|----|----|----| | |
| 25 | + | | ExeName | string | \- | Name of the executable. | | |
| 26 | + | | HelpFile | string | rw | Location of the application help file. | | |
| 27 | + | | Terminated | Boolean | \- | Was Terminate called or not | | |
| 28 | + | | Title | string | rw | Application title | | |
| 29 | + | | ConsoleApplication | Boolean | \- | Is the application a console application or not | | |
| 30 | + | | Location | string | \- | Application location | | |
| 31 | + | | Params\[\] | string | \- | Command-line parameters | | |
| 32 | + | | ParamCount | Integer | \- | Number of command-line parameters | | |
| 33 | + | | EnvironmentVariable\[\] | string | \- | Environment variable access | | |
| 34 | + | | OptionChar | Char | rw | Command-line switch character | | |
| 35 | + | | CaseSensitiveOptions | Boolean | rw | Are options interpreted case sensitive or not | | |
| 36 | + | | StopOnException | Boolean | rw | Should the program loop stop on an exception | | |
| 37 | + | | ExceptionExitCode | LongInt | rw | ExitCode to use then terminating the program due to an exception | | |
| 38 | + | | EventLogFilter | TEventLogTypes | rw | Event to filter events, before they are sent to the system log | | |
| 39 | + | | SingleInstance | TBaseSingleInstance | \- | Single instance used to control single application instance behaviour | | |
| 40 | + | | SingleInstanceClass | TBaseSingleInstanceClass | rw | Class to use when creating single instance | | |
| 41 | + | | SingleInstanceEnabled | Boolean | rw | Enable single application instance control. | | |
| 42 | + | | Active | Boolean | | True if the application has the focus. | | |
| 43 | + | | ApplicationType | TApplicationType | rw | The type of the application (i.e. the sort of device for which it is intended). | | |
| 44 | + | | BidiMode | TBiDiMode | rw | The bidirectional mode to use. | | |
| 45 | + | | CaptureExceptions | Boolean | rw | Enables exception handling by Application. | | |
| 46 | + | | DoubleBuffered | TApplicationDoubleBuffered | rw | platform | | |
| 47 | + | | ExtendedKeysSupport | Boolean | rw | | | |
| 48 | + | | ExceptionDialog | TApplicationExceptionDlg | rw | | | |
| 49 | + | | FindGlobalComponentEnabled | Boolean | rw | Enables searching for global components by name. | | |
| 50 | + | | Flags | TApplicationFlags | rw | Application state flags. | | |
| 51 | + | | Handle | THandle | rw | platform ; | | |
| 52 | + | | Hint | string | rw | The current Hint text. | | |
| 53 | + | | HintColor | TColor | rw | The color of Hint windows. | | |
| 54 | + | | HintHidePause | Integer | rw | How long a Hint stays visible, after an mouse move. | | |
| 55 | + | | HintHidePausePerChar | Integer | rw | How much a keystroke extends the time a Hint stays visible (added to HintHidePause). | | |
| 56 | + | | HintPause | Integer | rw | The delay before a Hint is shown. | | |
| 57 | + | | HintShortCuts | Boolean | rw | Enables the display of keyboard shortcuts (e.g. on menu entries). | | |
| 58 | + | | HintShortPause | Integer | rw | The pause before a different Hint is displayed. | | |
| 59 | + | | Icon | TIcon | rw | The icon associated with this application. | | |
| 60 | + | | LayoutAdjustmentPolicy | TLayoutAdjustmentPolicy | rw | | | |
| 61 | + | | Navigation | TApplicationNavigationOptions | rw | Allows to switch between controls by pressing keys. | | |
| 62 | + | | MainForm | TForm | | The application terminates when this form is closed. | | |
| 63 | + | | MainFormHandle | HWND | | the Handle of the MainForm | | |
| 64 | + | | MainFormOnTaskBar | Boolean | rw | platform | | |
| 65 | + | | ModalLevel | Integer | | The number of modal forms shown. | | |
| 66 | + | | MoveFormFocusToChildren | Boolean | rw | | | |
| 67 | + | | MouseControl | TControl | | The control currently under the mouse. | | |
| 68 | + | | TaskBarBehavior | TTaskBarBehavior | rw | How forms are represented in the TaskBar. | | |
| 69 | + | | UpdateFormatSettings | Boolean | rw | platform; | | |
| 70 | + | | Scaled | Boolean | rw | | | |
| 71 | + | ||
| 72 | + | Properties | |
| 73 | + | ||
| 74 | + | ## Events | |
| 75 | + | ||
| 76 | + | | Event | type | Description | | |
| 77 | + | |----|----|----| | |
| 78 | + | | OnException | TExceptionEvent | Exception handling event | | |
| 79 | + | | OnActionExecute | TActionEvent | Default handler for unhandled Actions | | |
| 80 | + | | OnActionUpdate | TActionEvent | Default handler for unhandled Action updates | | |
| 81 | + | | OnActivate | TNotifyEvent | activation of the application. | | |
| 82 | + | | OnDeactivate | TNotifyEvent | deactivation of the application. | | |
| 83 | + | | OnGetMainFormHandle | TGetHandleEvent | | | |
| 84 | + | | OnIdle | TIdleEvent | for application entering Idle state. | | |
| 85 | + | | OnIdleEnd | TNotifyEvent | for application leaving Idle state. | | |
| 86 | + | | OnEndSession | TNotifyEvent | for ending a session of the application | | |
| 87 | + | | OnQueryEndSession | TQueryEndSessionEvent | can deny to end the session. | | |
| 88 | + | | OnMinimize | TNotifyEvent | for application minimized. | | |
| 89 | + | | OnMessageDialogFinished | TModalDialogFinished | | | |
| 90 | + | | OnModalBegin | TNotifyEvent | for a modal form opened (application entering modal mode). | | |
| 91 | + | | OnModalEnd | TNotifyEvent | all modal forms closed (application exiting modal mode). | | |
| 92 | + | | OnRestore | TNotifyEvent | for application restored (from minimized/maximized state). | | |
| 93 | + | | OnDropFiles | TDropFilesEvent | The default handler for dropped files | | |
| 94 | + | | OnHelp | THelpEvent | when help is requested. | | |
| 95 | + | | OnHint | TNotifyEvent | when a hint is requested. | | |
| 96 | + | | OnShortcut | TShortCutEvent | interpret keystrokes as shortcuts, before the normal target handles the key. | | |
| 97 | + | | OnShowHint | TShowHintEvent | showing a Hint. | | |
| 98 | + | | OnUserInput | TOnUserInputEvent | | | |
| 99 | + | | OnDestroy | TNotifyEvent | | | |
| 100 | + | | OnCircularException | TExceptionEvent | Handler invoked when there is an exception circle before killing the app with Halt | | |
| 101 | + | | ShowButtonGlyphs | TApplicationShowGlyphs | Allows to override the platform default for glyphs on buttons. | | |
| 102 | + | | ShowMenuGlyphs | TApplicationShowGlyphs | Sets the default policy for showing or hiding glyph images in menus | | |
| 103 | + | | ShowHint | Boolean | Enables Hint display | | |
| 104 | + | | ShowMainForm | Boolean | Allows to show or hide the main form, on application start. Default TRUE. | | |
| 105 | + | | | | | | |
| 106 | + | ||
| 107 | + | Events | |
| 108 | + | ||
| 109 | + | ## see also | |
| 110 | + | ||
| 111 | + | - [[TCustomApplication]] | |
| 112 | + | - [[TApplicationProperties]] | |
| 113 | + | ||
| 114 | + | --- | |
| 115 | + | *From the Free Pascal wiki, page "TApplication", as it stood on 2020-11-22 after a change by Jwdietrich, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
