具有 Aero 效果的 Delphi XE 导致油漆问题
我已从 2009 年升级到 Delphi XE,但遇到了一个奇怪的问题。
我创建一个新项目,放下一个TRibbon控件,编译并运行。将表单保持为默认大小,然后最小化并恢复,不会出现任何问题。然后我最大化表单,最小化并恢复,表单颜色更改为黑色。
我没有随机代码来更改它,并且正在使用 Delphi XE 附带的所有默认值,并且它每次都会执行此操作,不会失败。
我已将编译后的 exe 移至朋友的计算机上,但问题仍然存在,所以我知道这不是我的计算机。如果我关闭 Aero 效果,问题就会消失,但是重新打开 Aero 效果,问题又会出现。
有什么想法吗?我无法在互联网上找到有关此问题的任何相关线程。
谢谢, Seb
编辑(根据要求,显示此行为的表单的 DFM。注意:这种情况发生在我启动的任何项目上):
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 555
ClientWidth = 989
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PrintScale = poNone
Scaled = False
PixelsPerInch = 96
TextHeight = 13
object Ribbon1: TRibbon
Left = 0
Top = 0
Width = 989
Height = 143
Caption = 'Ribbon1'
ExplicitLeft = 104
ExplicitTop = 296
ExplicitWidth = 0
StyleName = 'Ribbon - Luna'
end
end
一点也不奇怪,它只是一个具有单个表单的新项目。
I have upgraded to Delphi XE from 2009 and am experiencing a strange issue.
I create a new project, put down a TRibbon control, compile and run. Keeping the form in its default size I then minimize and restore without issues. I then maximise the form, minimize and restore and the form colour is changed to black.
I have no random code to change it and am using all defaults Delphi XE comes with and it does it each and every time without fail.
I have moved the compiled exe to a friends computer and the problem remains so I know it's not my computer. If I turn off Aero effects the problem goes away, but put Aero back on and the problem returns.
Any ideas at all? I'm having trouble finding any relevant threads regarding this issue across the interwebs.
Thanks,
Seb
Edit (as requested, the DFM for the Form that displays this behaviour. Note: This happens on any project I start):
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 555
ClientWidth = 989
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PrintScale = poNone
Scaled = False
PixelsPerInch = 96
TextHeight = 13
object Ribbon1: TRibbon
Left = 0
Top = 0
Width = 989
Height = 143
Caption = 'Ribbon1'
ExplicitLeft = 104
ExplicitTop = 296
ExplicitWidth = 0
StyleName = 'Ribbon - Luna'
end
end
Nothing fanciful at all, it's just a new project with a single form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够重现该错误,以下是我发现的一些问题。也许他们会帮助某人解决这个问题。
OnClick
事件中调用Invalidate
,表单将恢复其颜色。WndProc
在WM_SIZE
上使用wParam
=SIZE_MAXIMIZED
启用计时器,然后从计时器中调用Invalidate
,表单将恢复其颜色。这本质上与第一种方法(从按钮调用Invalidate
)相同,但计时器会自动执行此操作,并确保仅当没有更多消息时才调用Invalidate
被处理。我用一个简单的PostMessage
尝试了相同的操作,但没有成功(即:我可能太早Invalidate
了,这可能是另一个线索)Application.MainFormOnTaskbar := False
,我将不再看到黑色表单。解决方法
功能区占据了表单的顶部。将
TPanel
放在表单的其余部分上,使其Align = alClient
并将所有内容放在面板上。面板后面的黑色不再可见!I am able to reproduce the bug, here are some of the issues I discovered. Maybe they'll help someone figure this thing out.
Invalidate
from the button'sOnClick
event, the form gets it's colors back.WndProc
onWM_SIZE
withwParam
=SIZE_MAXIMIZED
, then callInvalidate
from the timer the form gets it's colors back. This is essentially the same as the first method (callingInvalidate
from a button), but the timer makes this automatic and ensuresInvalidate
is called only when there are no more messages to be processed. I tried the same with a simplePostMessage
but didn't work (ie: I was probablyInvalidate
-ing too soon, and that's probably an other clue)Application.MainFormOnTaskbar := False
in the project's source, I no longer see the black form.Workaround
The ribbon takes up the top part of the form. Place a
TPanel
on the rest of the form, make itAlign = alClient
and put everything on the Panel. The Black behind the panel is no longer visible!使用 Ribbon 时应启用玻璃框架,因为 Ribbon 控件专门设计用于与航空玻璃框架配合使用。其次,您应该做更多的工作来配置功能区,添加应用程序菜单和一些窗格,以使其按设计工作。我不相信没有任何选项卡组或系统菜单的“功能区本身”会在运行时正确呈现。
如果您希望功能区在启用了 Aero glass 的系统上工作,您应该启用玻璃框架属性 (Form.GlassFrame.Enabled) ,并打开 Form.DoubleBuffered 属性,添加一些选项卡页,添加一些选项卡组,并添加一个系统菜单。很多步骤。
请尝试附加的功能区启动器项目。 (ribbonStarter.zip 88k)
更新 如果我的ribbonStarter 在您的系统上产生相同的结果,也许这应该记录在Quality Central 中。这可能是您的视频驱动程序中的错误,可以在功能区和表单代码中制作一些代码解决方法。
You should enable glass frame when using Ribbon, because the Ribbon control is especially designed to work with aero glass frames on. Secondly you should do a little more work to configure your ribbon, adding an application menu, and some panes, to have it work as designed. I don't believe that "ribbon by itself" without any tab groups, or a system menu, is going to render properly at runtime.
If you want the ribbon to work on systems with Aero glass enabled, you should enable the glass frame property (Form.GlassFrame.Enabled) , and turn on Form.DoubleBuffered property, add some tab pages, add some tab groups, and add a system menu. Lots of steps.
Please try the attached ribbon starter project. (ribbonStarter.zip 88k)
Update If even my ribbonStarter produces the same result on your system, perhaps this should be logged in Quality Central. It is possibly a bug in your video driver, for which some code workaround in the ribbon and form code could be made.