Error while creating the TChromium in Inno Setup

395 views Asked by At

I'm trying to create a DLL of TChromium to use in Inno Setup, equal to TLama made ​​with TWebBrowser, creating inno-web-browser, but I can not, I'm following the same logic of the basic procedures, but during the creation, is created window within the inno setup is strange though, was leaving the annexed print, showing the image.

Edit: I'm using Delphi XE2 and DCEF3.

procedure CreateChromium(ParentWnd: HWND; Left, Top, Width, Height: Integer);
begin
  Chromium := TChromium.Create(nil);
  Chromium.ParentWindow := ParentWnd;
  Chromium.Left := Left;
  Chromium.Top := Top;
  Chromium.Width := Width;
  Chromium.Height := Height;
  Chromium.Visible := true;
  Chromium.HandleNeeded;
end;

Print Screen

1

There are 1 answers

2
TLama On BEST ANSWER

The Chromium control has on your screenshot its default color, so if that's your problem, let's change it to a different color. I wrote about it in this post which was for DCEF1 but in DCEF3 you need to do similar steps. Take a look at this minimalistic code for your plugin which adds to the initialization function new Color parameter and shows how to set Chromium control background color:

unit MainUnit;

interface

uses
  Winapi.Windows, System.SysUtils, Vcl.Graphics, Vcl.GraphUtil, Soap.EncdDecd,
  CefVCL;

procedure CreateChromium(ParentWnd: HWND; Color: TColor; Left, Top, Width,
  Height: Integer); stdcall;

implementation

var
  Chromium: TChromium;

procedure CreateChromium(ParentWnd: HWND; Color: TColor; Left, Top, Width,
  Height: Integer);
const
  CSSHeader = 'data:text/css;charset=utf-8;base64,';
begin
  Chromium := TChromium.Create(nil);
  Chromium.ParentWindow := ParentWnd;

  // here is the tricky part; you must take the constant CSS header part and
  // concatenate it with Base64 encoded CSS style string as shown here
  Chromium.UserStyleSheetLocation := CSSHeader +
    EncodeString(Format('body {background-color:%s;}',
    [ColorToWebColorStr(Color)]));
  // and after you set the style, you need to recreate the browser
  Chromium.ReCreateBrowser('about:blank');

  Chromium.Left := Left;
  Chromium.Top := Top;
  Chromium.Width := Width;
  Chromium.Height := Height;
end;

end.