如何更改 TChromium 组件的默认背景颜色?
我使用 TChromium
。我指定 AWebPageAsString
这是一个带有灰色背景颜色的静态 HTML 页面。
FBrowser := TChromium.Create(pnlHolder);
FBrowser.Visible := false;
FBrowser.Parent := TWinControl(pnlHolder);
FBrowser.Align := alClient;
FBrowser.OnBeforeBrowse := BrowserBeforeBrowse;
FBrowser.HandleNeeded;
FBrowser.FontOptions.RemoteFontsDisabled := true;
FBrowser.Browser.MainFrame.LoadString(AWebPageAsString, 'navigate:webpage');
当我启动应用程序时,它首先显示为白色背景和空内容,然后我的页面显示为灰色背景和实际内容。
有办法避免这种情况吗?也许有默认的背景颜色?
I use TChromium
. I assign AWebPageAsString
which is a static HTML page with a gray background color.
FBrowser := TChromium.Create(pnlHolder);
FBrowser.Visible := false;
FBrowser.Parent := TWinControl(pnlHolder);
FBrowser.Align := alClient;
FBrowser.OnBeforeBrowse := BrowserBeforeBrowse;
FBrowser.HandleNeeded;
FBrowser.FontOptions.RemoteFontsDisabled := true;
FBrowser.Browser.MainFrame.LoadString(AWebPageAsString, 'navigate:webpage');
When I start the application it is displayed first with white background and empty content and then my page gets displayed with gray background and actual content.
Is there a way to avoid this ? Maybe have a default background color ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道,这是一个很晚的答案,但它至少是一个有趣的话题。要更改默认浏览器的背景颜色,您可以使用自定义样式表。听起来不错,但它有一个很大的弱点 - 当您导航到没有定义样式表的页面时,将应用您的自定义样式表。但是,如果您知道您将仅浏览特定样式的页面,那么这甚至可能是有利的,因为这样您就可以保留在默认自定义样式中定义的样式定义。
因此,要创建一个黑色背景的浏览器(使用下面描述的样式),您可以使用以下代码:
上面代码中使用的
CSSBase64
常量是以下样式表编码为 Base64
:Quite a late answer, I know, but it's at least an interesting topic. To change default browser's background color you can use a custom stylesheet. It sounds good, but it has one big weakness - when you navigate to a page that has e.g. no stylesheet defined, your custom one will be applied. But if you know that you'll browse e.g. only your pages in a certain style, it might be even advantage, since then you can leave the style definitions defined in that default custom style.
So to create a browser with a black background (using the style described below) you can use this code:
The
CSSBase64
constant used in the above code is the following stylesheetencoded to Base64
: