Skip to content

CustomApplication

Global application instance.

Declaration

Source position: custapp.pp line 125

var
  CustomApplication: type

  TCustomApplication = class(TComponent)
  public
    constructor Create(AOwner: TComponent);  override;
    destructor Destroy;  override;
    procedure HandleException(Sender: TObject);  virtual;
    procedure Initialize;  virtual;
    procedure Run;
    procedure ShowException(E: Exception);  virtual;
    procedure Terminate;  virtual;
    procedure Terminate(AExitCode: Integer);  virtual;
    function FindOptionIndex(const S: string; var Longopt: Boolean; 
                        StartAt: Integer=- 1) : Integer;
    function GetOptionValue(const S: string) : string;
    function GetOptionValue(const C: char; const S: string) : string;
    function GetOptionValues(const C: char; const S: string) : TStringArray;
    function HasOption(const S: string) : Boolean;
    function HasOption(const C: char; const S: string) : Boolean;
    function CheckOptions(const ShortOptions: string; 
                     const Longopts: TStrings; Opts: TStrings; 
                     NonOpts: TStrings; AllErrors: Boolean=False)
                      : string;
    function CheckOptions(const ShortOptions: string; 
                     const Longopts: Array of string = string; 
                     Opts: TStrings; NonOpts: TStrings; 
                     AllErrors: Boolean=False) : string;
    function CheckOptions(const ShortOptions: string; 
                     const Longopts: TStrings; AllErrors: Boolean=False)
                      : string;
    function CheckOptions(const ShortOptions: string; 
                     const LongOpts: Array of string = string; 
                     AllErrors: Boolean=False) : string;
    function CheckOptions(const ShortOptions: string; 
                     const LongOpts: string; AllErrors: Boolean=False)
                      : string;
    function GetNonOptions(const ShortOptions: string; 
                      const Longopts: Array of string = string)
                       : TStringArray;
    procedure GetNonOptions(const ShortOptions: string; 
                       const Longopts: Array of string = string; 
                       NonOptions: TStrings);
    procedure GetEnvironmentList(List: TStrings; NamesOnly: Boolean);
    procedure GetEnvironmentList(List: TStrings);
    procedure Log(EventType: TEventType; const Msg: string);
    procedure Log(EventType: TEventType; const Fmt: string; 
             const Args: Array of const);
    property ExeName: string read GetExeName;
    property HelpFile: string read FHelpFile write FHelpFile;
    property Terminated: Boolean read FTerminated;
    property Title: string read FTitle write SetTitle;
    property OnException: TExceptionEvent read FOnException write FOnException;
    property ConsoleApplication: Boolean read GetConsoleApplication;
    property Location: string read GetLocation;
    property Params[Index : Integer]: string read GetParams;
    property ParamCount: Integer read GetParamCount;
    property EnvironmentVariable[envName : string]: string read GetEnvironmentVar;
    property OptionChar: char read FoptionChar write FOptionChar;
    property CaseSensitiveOptions: Boolean read GetCaseSensitiveOptions write SetCaseSensitiveOptions;
    property CaseSensitiveShortOptions: Boolean read FCaseSensitiveShortOptions write FCaseSensitiveShortOptions;
    property CaseSensitiveLongOptions: Boolean read FCaseSensitiveLongOptions write FCaseSensitiveLongOptions;
    property StopOnException: Boolean read FStopOnException write FStopOnException;
    property ExceptionExitCode: LongInt read FExceptionExitCode write FExceptionExitCode;
    property EventLogFilter: TEventLogTypes read FEventLogFilter write FEventLogFilter;
    property SingleInstance: TBaseSingleInstance read GetSingleInstance;
    property SingleInstanceClass: TBaseSingleInstanceClass read FSingleInstanceClass write SetSingleInstanceClass;
    property SingleInstanceEnabled: Boolean read FSingleInstanceEnabled write FSingleInstanceEnabled;
  end = Nil;

Description

CustomApplication contains the global application instance. All descendents of TCustomApplication should, in addition to storing an instance pointer in some variable (most likely called "Application") store the instance pointer in this variable. This ensures that, whatever kind of application is being created, user code can access the application object.

See also

Name Description
TCustomApplication Ancestor class for TApplication classes.