按 Alt 键清除嵌入的 TWebBrowser
我将 TWebBrowser 嵌入到 TForm 中。 每当我按下 Alt 按钮时,浏览器窗口就会变成白色。如果我拖动表单,它会正确重新绘制。
我做错了什么?
我有 DevExpress Bars 和 Quantum Grid,如果这很重要的话?
我使用 Delphi 2010 和 Windows 7 和 XP SP2。 IE 版本为 7 和 8。在所有版本上均可重现。
按 Alt 之前:
按 Alt 后:
我已通过使用以下命令解决了该问题:
procedure TMainForm.WndProc(var Message: TMessage);
begin
inherited WndProc(Message);
if Message.Msg = WM_UPDATEUISTATE then
begin
if Assigned(ProblematicWebBrowser) then
ProblematicWebBrowser.Repaint;
end;
end;
I have TWebBrowser embedded in a TForm.
Whenever I press Alt button the browser window becomes white. If I drag the form around it repaints correctly.
What I am doing wrong?
I have DevExpress Bars and Quantum Grid if that matters?
I use Delphi 2010 and Windows 7 and XP SP2. IE version is 7 and 8. Reproducible on all.
Before pressing Alt:
After pressing Alt:
I have resolved it by usnig the following:
procedure TMainForm.WndProc(var Message: TMessage);
begin
inherited WndProc(Message);
if Message.Msg = WM_UPDATEUISTATE then
begin
if Assigned(ProblematicWebBrowser) then
ProblematicWebBrowser.Repaint;
end;
end;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你没有说你正在使用什么版本的Delphi,你正在使用什么版本的Windows,或者你安装了什么版本的IE,这是TWebBrowser 包装的内容。 (一般来说,因为您是这里的新用户,所以在提出这样的问题时,您确实需要提供更多信息。假设是您的软件的用户报告了此错误 - 您会举起手说“啊,没有复制。为什么他们不能告诉我他们在做什么?”当我们阅读你的问题时也是如此。)
但是,也就是说,当你按下 Alt 键时它会消失,这是一个提示。 Windows 有一个选项可以隐藏加速键(下划线标记,例如文件菜单上带下划线的 F),直到用户按下 Alt 键。当它发生时,控件将被发送 WM_DRAWITEM 消息表明某些内容已更改。另请参阅 WM_CHANGEUISTATE。
Delphi 的过去版本在处理此问题时存在错误(请参阅此示例错误)包括一个错误,其中 按下 Alt 键时控件完全消失。 TWebBrowser 未列在该 QC 项目中,但它很可能受到影响。
所以我的猜测是:
主题
这正在影响
TWebBrowser 控件或其父控件
解决方案:升级 Delphi 或应用 QC 项目。
You don't say what version of Delphi you're using, what version of Windows you're using, or what version of IE you have installed, which is what TWebBrowser wraps. (As a general note because you're a new user here, you really need to provide more information when asking a question like this. Pretend it was a user of your software reporting this bug - you'd throw your hands up and say "Bah, not reproduced. Why can't they tell me what they're doing?" Same for us when reading your question.)
But, that said, the fact it vanishes when you press the Alt key is a hint. Windows has an option to hide accelerator keys (the underline mark such as the underlined F on a File menu) until the user presses the Alt key. When it does, controls are sent a WM_DRAWITEM message indicating something's changed. See also WM_CHANGEUISTATE.
There have been bugs in past versions of Delphi handling this (see this example bug) including a bug where controls completely vanished when the Alt key was pressed. TWebBrowser isn't listed in that QC item, but it's quite possible it's affected.
So my guess is:
themed
which is affecting either the
TWebBrowser control or a parent of it
Solution: upgrade Delphi or apply the fix listed in the QC item.
FWIW,在 D2010 中使用带有 TWebBrowser 的普通表单,按 Alt 对 WebBrowser 显示没有影响。
FWIW, with a plain vanilla Form with a TWebBrowser in D2010, pressing Alt has not effect on the WebBrowser display.