具有 Aero 效果的 Delphi XE 导致油漆问题

发布于 2024-11-17 05:18:12 字数 1055 浏览 6 评论 0原文

我已从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

野心澎湃 2024-11-24 05:18:12

我能够重现该错误,以下是我发现的一些问题。也许他们会帮助某人解决这个问题。

  • 如果我在表单上放置一个按钮并从按钮的 OnClick 事件中调用 Invalidate,表单将恢复其颜色。
  • 如果我在表单上放置一个计时器,请从 WndProcWM_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.

  • If I place a button on the form and call Invalidate from the button's OnClick event, the form gets it's colors back.
  • If I place a place a timer on the form, enable the timer from WndProc on WM_SIZE with wParam = SIZE_MAXIMIZED, then call Invalidate from the timer the form gets it's colors back. This is essentially the same as the first method (calling Invalidate from a button), but the timer makes this automatic and ensures Invalidate is called only when there are no more messages to be processed. I tried the same with a simple PostMessage but didn't work (ie: I was probably Invalidate-ing too soon, and that's probably an other clue)
  • Interesting: If I make 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 it Align = alClient and put everything on the Panel. The Black behind the panel is no longer visible!

眼眸里的那抹悲凉 2024-11-24 05:18:12

使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文