在Inno Setup中创建TChromium时出错

时间:2013-09-02 06:20:44

标签: inno-setup tchromium

我正在尝试创建一个用于Inno Setup的TChromium DLL,等同于用TWebBrowser制作的TLama,创建inno-web-browser,但我不能,我遵循基本相同的逻辑程序,但在创建过程中,创建窗口内的inno设置虽然很奇怪,但正在留下附件的打印件,显示图像。

编辑:我正在使用Delphi XE2和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 个答案:

答案 0 :(得分:2)

Chromium控件在你的屏幕截图上有默认颜色,所以如果这是你的问题,让我们把它改成不同的颜色。我写了关于DCEF1的in this post,但是在DCEF3中你需要做类似的步骤。看看这个插件的简约代码,它添加了初始化函数new Color参数,并展示了如何设置Chromium控件背景颜色:

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.