TRibbon 不显示选项卡

发布于 2024-12-20 10:27:22 字数 624 浏览 2 评论 0原文

我在 64 位 Windows 计算机 (Win 7) 和 32 位 Windows 计算机 (XP) 上运行 Delphi 2010。

我正在尝试学习如何使用 TRibbon 控件。

我一直在遵循 Marco Cantu 2009 年手册中的示例并观看 YouTube 演示,但我的控制并不像书中或演示中所解释的那样工作。

我通过右键单击控件添加了两个选项卡。然而,当我将 TRibbon 放在主窗体上时,它看起来与我的屏幕截图中的一模一样。它不像书本或 YouTube 演示中的那么高。

我在运行 Windows Xp 和 Delphi 2010 的 Win 32 笔记本电脑上尝试了同样的操作,并得到了完全相同的结果,

这就是我的机器上的样子

64 位笔记本电脑屏幕截图

这是演示中的样子

from youtube video demo

再次。当它把它放在表单上时,它的形状和高度并不像我在演示中看到的那样。即使我添加标签。我在安装 Delphi 2010 的过程中是否做错了什么?

I am running Delphi 2010 on both a 64 bit windows machine (Win 7), and a 32 bit windows machine (XP).

I am trying to learn how to use the TRibbon control.

I have been following the example in Marco Cantu's 2009 Handbook and watching YouTube Demos, but my control is not working like that as explained in the book or demos.

I added two tabs, by right clicking the control. However, the TRibbon looked as exactly as it does in my screenshot, when i drop it on the main form. It is not as high as the ones in the books or youtube demos.

I have tried the same thing on my Win 32 laptop running Windows Xp and Delphi 2010 and get the exact same results

here is what it looks like on my machine

64 bit laptop screenshot

here is what it is suppose to look like in a demo

from youtube video demo

Once again. When it drop it on the form, it does not take the shape and height as that as i see in the demos. Even when i add tabs. Did i do something wrong during my Delphi 2010 installation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

丑丑阿 2024-12-27 10:27:22

我终于在启用了 Aero 的 Win7 64 上的 Delphi XE(更新 1)中重现了该问题。 .DFM 文件中的大小似乎设置错误,并且由于 Ribbon 不支持手动调整大小,因此您无法在 IDE 中直观地修复它(尽管它在运行时) 或在对象检查器 中。它偶尔会在运行时正确显示,但似乎也是零星的。

这是一个令人讨厌的错误,因为它使得设计 Ribbon 变得不可能。您可以添加RibbonGroup项,并分配ActionManager,并尝试完全使用Structure Pane进行设计,但这当然不切实际解决方案。

幸运的是,有一个非常简单的解决方法,尽管必须这样做很烦人。 :)

我两次设法让以下解决方法发挥作用,但重新开始几次都失败了,所以这是一种可能的解决方法(没有承诺 - 在 XE 中有效,在 XE2 Update 2 中始终失败):

  • 右键单击Ribbon并添加至少一个选项卡。
  • 右键单击 IDE 中的表单,然后从上下文(弹出)菜单中选择以文本方式查看
  • .dfm文本中找到Ribbon控件,并将Height从IDE分配的26更改为200。 (下一步将对其进行调整,但没关系 - 200 解决了眼前的问题。)
  • 再次右键单击,然后选择View as Form,然后 功能区应该正确显示。

(我在针对 XE2 Update 2 的 QC 中报告了该问题,因为该问题也存在 - QC #101642

我追踪到 TCustomRibbon.GetCaptionHeight,特别是

FCaptionHeight := Max(GetSystemMetrics(SM_CYCAPTION), 26);

它似乎是 GetSystemMetrics 调用在某些 Win7 配置上返回小于 26 的值(尽管我还不知道为什么)。该方法中有几行注释行似乎会改变结果,但正如我所说,它们已被注释掉。

奇怪的是,在 TCustomRibbon.Create 中,Height 是通过调用 GetRibbonMetric(rmFullHeight) 来设置的,这会设置 >Result := cRibbonHeight + GetCaptionHeight;,并且 cRibbonHeight 是一个常量,定义为 cRibbonHeight = 117;

最后我想我已经找到了这个。在 TRibbon 的声明中,有一个 published 属性声明:

published
   ...
  property Height default TCustomRibbon.cRibbonHeight;

因为这是默认值,所以任何其他值似乎都意味着对 GetRibbonMetric 的调用> 上面提到的情况不会发生(参见上面提到的 TCustomRibbon.Create),并且调用 GetSystemMetric 的奇怪结果会导致错误的值26 保存为“其他值”。奇怪;将在上午更新 QC。

附录:更新了 QC 报告并提供了更多详细信息。

附录:质量控制报告于 2012 年 5 月开放,但似乎没有自 XE5 Update 1 起已解决(2014 年 1 月检查)。

I managed finally to reproduce the problem in Delphi XE (Update 1) on Win7 64 with Aero enabled. It seems that the size gets set wrong in the .DFM file, and because the Ribbon doesn't support manual resizing you can't visually fix it in the IDE (although it appears correctly at runtime) or in the Object Inspector. It occasionally appears correctly at runtime, but it seems that's sporadic as well.

It's a nasty bug, because it makes it impossible to design the Ribbon. You can add RibbonGroup items, and assign the ActionManager, and try and design it completely using the Structure Pane, but of course that's not a practical solution.

Fortunately, there's a pretty easy workaround, although it's annoying to have to do. :)

I managed twice to get the following workaround to function, but starting over it failed to work several times, so it's a possible way around it (no promises - worked in XE, consistently failed in XE2 Update 2):

  • Right-click on the Ribbon and add at least one tab.
  • Right click on the form in the IDE, and choose View as Text from the context (pop-up) menu.
  • Find the Ribbon control in the .dfm text, and change the Height from the 26 that the IDE assigned to 200. (The next step will adjust it, but that's fine - the 200 fixes the immediate problem.)
  • Right-click again, and choose View as Form, and the Ribbon should display correctly.

(I reported it in QC against XE2 Update 2, as the problem also exists there - QC #101642)

I traced it to TCustomRibbon.GetCaptionHeight, specifically

FCaptionHeight := Max(GetSystemMetrics(SM_CYCAPTION), 26);

It seems like the GetSystemMetrics call is returning something less than 26 on certain Win7 configurations (although I can't figure out why yet). There are a couple of commented lines in that method that seem to alter the result, but as I said they've been commented out.

The strange part is that in the TCustomRibbon.Create, the Height is set by a call to GetRibbonMetric(rmFullHeight), which sets the Result := cRibbonHeight + GetCaptionHeight;, and cRibbonHeight is a constant defined as cRibbonHeight = 117;.

Finally think I've tracked this down. In the declaration of TRibbon, there's a published property declaration:

published
   ...
  property Height default TCustomRibbon.cRibbonHeight;

Because this is the default, it appears that any other value means that the call to GetRibbonMetric mentioned above doesn't happen (see the TCustomRibbon.Create mentioned above), and the strange result from the call to GetSystemMetric causes the erroneous value 26 to be saved as the 'other value`. Wierd; will update the QC in the AM.

Addendum: Updated QC report with additional details.

Addendum: QC report opened in May 2012, but does not appear to have been resolved as of XE5 Update 1 (checked Jan 2014).

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