Chromium 控件在您的屏幕截图上有其默认颜色,所以如果这是您的问题,让我们将其更改为不同的颜色。我写过它in this post
是针对 DCEF1 的,但在 DCEF3 中你需要执行类似的步骤。看看这个为您的插件添加了初始化函数新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.