title: How to initialize an embedded chrome browser component on a secondary form
body: <p>I installed dcef3 the Delphi Chromium Embedded 3 component into Delphi XE4.  I obtained the component from: <a href="http://code.google.com/p/dcef3/" rel="nofollow">http://code.google.com/p/dcef3/</a>. The guiclient demo runs perfectly with no perceived problems.  </p>
  
  <p>Then I attempted to add the guiclient form to my own demo application as a secondary form... not the main form. I added a button that creates the guiclient form at runtime and attempts to show it modally but an exception is produced when the guiclient form is produced. </p>
  
  <p>Looking over the guiclient dpr I find this:</p>
  
  <pre><code>program guiclient;
  
  uses
    sysutils,
    ceflib,
    Windows,
    Forms,
    main in 'main.pas' {MainForm},
    ceffilescheme in '..\filescheme\ceffilescheme.pas';
  
  {$R *.res}
  
  procedure RegisterSchemes(const registrar: ICefSchemeRegistrar);
  begin
    registrar.AddCustomScheme('local', True, True, False);
  end;
  
  begin
    CefOnRegisterCustomSchemes := RegisterSchemes;
    CefSingleProcess := False;
    if not CefLoadLibDefault then
      Exit;
  
    CefRegisterSchemeHandlerFactory('local', '', False, TFileScheme);
  
    Application.Initialize;
    Application.CreateForm(TMainForm, MainForm);
    Application.Run;
  </code></pre>
  
  <p>end.</p>
  
  <p>Apparently when the guiclient demo runs it calls registersschemes. CefLoadDefault and registers the SchemeHandlerFactory in the dpr. </p>
  
  <p><strong>My question is... it necessary to registerschemes and call the initialization code in the OnFromCreate of the secondary form or in another event of my secondary form before the component will operate correctly?  What event should I try to initialize the component so it can run in a secondary form?  Are any dll's required to be in the applications folder?  If so which one?</strong></p>
  
  <p>The browser form is not created automatically in my demo.  I have a button on my main form that attempts to shown the browser form:</p>
  
  <pre><code>procedure TForm1.Browse1Click(Sender: TObject);
  begin
    FormBrowser := TFormBrowser.Create(self);
    try
      FormBrowser.ShowModal;
    finally
      FormBrowser.Free;
    end;
  end;
  </code></pre>
  
  <p>I attempted to initialize by putting code in the Browser1Click event and initialize before the form containing the component is created hoping that would work, but that produces an exception as well.  <strong>Maybe I need to create the component at runtime?</strong></p>
  
  <pre><code>procedure TForm1.Browse1Click(Sender: TObject);
  begin
    { Initialize the browser }
    CefOnRegisterCustomSchemes := RegisterSchemes;
    CefSingleProcess := False;
    if not CefLoadLibDefault then
      Exit;
  
    CefRegisterSchemeHandlerFactory('local', '', False, TFileScheme);
  
    FormBrowser := TFormBrowser.Create(self);
    try
      FormBrowser.ShowModal;
    finally
      FormBrowser.Free;
    end;
  end;
  </code></pre>
  
  <p>Any code showing me where and how to initialize the component in the secondary form would be appreciated. I can add more information to my post if needed. </p>
  
  <p>Isn't it unusual to have to initialize a component at runtime... I have not seen this type of approach to initialize a component before.</p>