MEGA Search
20.3 Million


Sign Up
From: Chief Archy  
Subject: Are TApplication and TServiceApplication treated as singleto
NewsGroup: borland.public.delphi.rtl.win32
Date Posted: 15-Apr-2004 at 8:40:11 PST
(not sure is this is the right forum)

Both do not appear to be designed like a singletons but only appear to be
used like one.

I did find in SvcMgr unit that the global TServiceApplication instance is
created in the initialization section and destroyed in finalization.

Where can I find the code where the TApplication instance is created? I've
been searching Forms unit and I can't find the code.


TIA,

    - Archy







From: Chief Archy  
Subject: Re: Are TApplication and TServiceApplication treated as sing
NewsGroup: borland.public.delphi.rtl.win32
Date Posted: 16-Apr-2004 at 8:34:15 PST
"Rob Kennedy" wrote...
> Search the source code for "TApplication.Create".


The constructor does not show how the global Forms.Application instance
variable is instantiated. Where is the Forms.Application global instance
variable instantiated?



(pasted from Delphi6)

constructor TApplication.Create(AOwner: TComponent);
var
  P: PChar;
  ModuleName: array[0..255] of Char;
begin
  inherited Create(AOwner);
  if not Assigned(Classes.ApplicationHandleException) then
    Classes.ApplicationHandleException := HandleException;
  if not Assigned(Classes.ApplicationShowException) then
    Classes.ApplicationShowException := ShowException;
  FBiDiMode := bdLeftToRight;
  FTopMostList := TList.Create;
  FWindowHooks := TList.Create;
  FHintControl := nil;
  FHintWindow := nil;
  FHintColor := DefHintColor;
  FHintPause := DefHintPause;
  FHintShortCuts := True;
  FHintShortPause := DefHintShortPause;
  FHintHidePause := DefHintHidePause;
  FShowHint := False;
  FActive := True;
  FAutoDragDocking := True;
  FIcon := TIcon.Create;
  FIcon.Handle := LoadIcon(MainInstance, 'MAINICON');
  FIcon.OnChange := IconChanged;
  GetModuleFileName(MainInstance, ModuleName, SizeOf(ModuleName));
  OemToAnsi(ModuleName, ModuleName);
  P := AnsiStrRScan(ModuleName, '\');
  if P <> nil then StrCopy(ModuleName, P + 1);
  P := AnsiStrScan(ModuleName, '.');
  if P <> nil then P^ := #0;
  AnsiLower(ModuleName + 1);
  FTitle := ModuleName;
  if not IsLibrary then CreateHandle;
  UpdateFormatSettings := True;
  UpdateMetricSettings := True;
  FShowMainForm := True;
  FAllowTesting := True;
  FTestLib := 0;
  ValidateHelpSystem;
  HookSynchronizeWakeup;
end;



From: Rob Kennedy  
Subject: Re: Are TApplication and TServiceApplication treated as sing
NewsGroup: borland.public.delphi.rtl.win32
Date Posted: 15-Apr-2004 at 10:41:15 PST
Chief Archy wrote:
> Where can I find the code where the TApplication instance is created? I've
> been searching Forms unit and I can't find the code.

Search the source code for "TApplication.Create".

-- 
Rob

From: Chief Archy  
Subject: Gentlemen, Thank you!!!
NewsGroup: borland.public.delphi.rtl.win32
Date Posted: 19-Apr-2004 at 16:2:46 PST
* Rob Kennedy
* Dave Nottage
* Nick Hodges


Thank you,

    - Archy



From: Nick Hodges (TeamB)  
Subject: Re: Are TApplication and TServiceApplication treated as sing
NewsGroup: borland.public.delphi.rtl.win32
Date Posted: 16-Apr-2004 at 17:46:6 PST
Dave Nottage (TeamB) wrote:

> In the Controls unit, in the InitControls procedure.

Which is called in the initialization section of forms.pas.

-- 
Nick Hodges -- TeamB
Lemanix Corporation -- http://www.lemanix.com
Read my Blog -- http://www.lemanix.com/nick

From: Dave Nottage (TeamB)  
Subject: Re: Are TApplication and TServiceApplication treated as sing
NewsGroup: borland.public.delphi.rtl.win32
Date Posted: 16-Apr-2004 at 16:47:49 PST
"Chief Archy"  wrote:

> The constructor does not show how the global Forms.Application
> instance variable is instantiated. Where is the Forms.Application
> global instance variable instantiated?

In the Controls unit, in the InitControls procedure. In Delphi 7, it's 
line 10924 of Controls.PAS.

-- 
Dave Nottage (TeamB)