0

I have an issue trying to create Delphi Chromium Embedded instance with code

var
  Chromium: TChromium;
begin
  Chromium := TChromium.Create(TcxTabSheet1);
  Chromium.Parent := TWinControl(TcxTabSheet1);
  Chromium.Align := alClient;
  Assert(Assigned(Chromium.Browser), 'HERE! Why Browser is not assigned.');
  ...
end;

Seems like Browser property is initialized when

procedure TCustomChromium.CreateWindowHandle(const Params: TCreateParams);

is called.

Why CreateWindowHandle is not called in my code?

Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
  • Because nothing has been done yet that calls HandleNeeded (which will call CreateWindowHandle when none has been assigned yet). – Marjan Venema Dec 04 '11 at 09:59
  • If you put your comment as an answer I will accept it. Indeed calling explicitly HandleNeeded solved the problem. – Gad D Lord Dec 04 '11 at 11:12

1 Answers1

3

My comment as an answer:

The reason Chromium.Browser is not yet assigned, when the Browser property is initialized from the CreateWindowHandle, is:

Because nothing has been done yet that calls HandleNeeded (which will call CreateWindowHandle when none has been assigned yet)

Marjan Venema
  • 19,136
  • 6
  • 65
  • 79
  • 1
    Can I add a suggestion: Don't use *Chromium.Parent := TWinControl(TcxTabSheet1);*, use *Chromium.SetParentComponent(TcxTabSheet1);* instead! – LaKraven Dec 04 '11 at 15:56