Search code examples
delphidelphi-xe2tracecodesite

How to trace the creation of controls/components on program startup?


In the DPR file of my Delphi XE2 VCL Form project, I have this code:

CodeSite.Send('DPR Before CreateForm');
Application.CreateForm(TformMain, formMain);

And at the start of the FormCreate event handler this code:

procedure TformMain.FormCreate(Sender: TObject);
begin
  CodeSite.Send('1 FormCreate');

However, BETWEEN these two CodeSite statements (where the controls and components on the form are created), the program crashes. (I can see this in the CodeSite Live Viewer, where DPR Before CreateForm is the last log entry).

So how can I find out which of the controls or components creation makes the program crash?


Solution

  • Found the cause of the crash/bug: I have a TEmbeddedWB on the main form. In FormCreate I had this statement which caused the crash/bug:

    EmbeddedWB1.SetCharartersSet('_autodetect_all');
    

    By simply moving this statement to FormShow the crash/bug disappeared. Obviously the Ole connection to Internet Explorer is not yet established in FormCreate (while in FormShow it seems it is).