[Overview][Types][Classes][Variables][Index] | Reference for unit 'CustApp' (#fcl)

# TCustomApplication

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

Ancestor class for TApplication classes.

## Declaration

Source position: custapp.pp line 29

`type TCustomApplication = class(TComponent)`
`protected`
`procedure SetTitle(); virtual;`
`function GetConsoleApplication; virtual;`
`procedure DoRun; virtual;`
`function GetParams(); virtual;`
`function GetParamCount; virtual;`
`procedure DoLog(); virtual;`
`public`
`constructor Create(); override;` |  | Create a new instance of the TCustomApplication class
`destructor Destroy; override;` |  | Destroys the TCustomApplication instance.
`procedure HandleException(); virtual;` |  | Handle an exception.
`procedure Initialize; virtual;` |  | Initialize the application
`procedure Run;` |  | Runs the application.
`procedure ShowException(); virtual;` |  | Show an exception to the user
`procedure Terminate; virtual;` |  | Terminate the application.
`function FindOptionIndex();` |  | Return the index of an option.
`function GetOptionValue();` |  | Return the value of a command-line option.
`function HasOption();` |  | Check whether an option was specified.
`function CheckOptions();` |  | Check whether all given options on the command-line are valid.
`procedure GetEnvironmentList();` |  | Return a list of environment variables.
`procedure Log();` |  | Write a message to the event log
`property ExeName: String; [r]` |  | Name of the executable.
`property HelpFile: String; [rw]` |  | Location of the application help file.
`property Terminated: Boolean; [r]` |  | Was Terminate called or not
`property Title: String; [rw]` |  | Application title
`property OnException: TExceptionEvent; [rw]` |  | Exception handling event
`property ConsoleApplication: Boolean; [r]` |  | Is the application a console application or not
`property Location: String; [r]` |  | Application location
`property Params: String; [r]` |  | Command-line parameters
`property ParamCount: Integer; [r]` |  | Number of command-line parameters
`property EnvironmentVariable: String; [r]` |  | Environment variable access
`property OptionChar: Char; [rw]` |  | Command-line switch character
`property CaseSensitiveOptions: Boolean; [rw]` |  | Are options interpreted case sensitive or not
`property StopOnException: Boolean; [rw]` |  | Should the program loop stop on an exception
`property EventLogFilter: TEventLogTypes; [rw]` |  | Event to filter events, before they are sent to the system log
`end;`

## Inheritance

`TCustomApplication` |  | Ancestor class for TApplication classes.
`TComponent,IUnknown,IInterfaceComponentReference`
`TPersistent`
`TObject`

## Description

TCustomApplication is the ancestor class for classes that whish to implement a global application class instance. It introduces several application-wide functionalities.

- Exception handling in HandleException, ShowException, OnException and StopOnException.
- Command-line parameter parsing in FindOptionIndex, GetOptionValue, CheckOptions and HasOption
- Environment variable handling in GetEnvironmentList and EnvironmentVariable.

Descendent classes need to override the DoRun protected method to implement the functionality of the program.

The latest version of this document can be found at lazarus-ccr.sourceforge.net .