TRibbon不显示选项卡 [英] TRibbon does not show tabs

查看:204
本文介绍了TRibbon不显示选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



我一直在Marco Cantu的2009年手册中看到示例,并观看YouTube演示,但是我的控制不像在书本或演示。



我添加了两个选项卡,右键单击控件。但是,在我的屏幕截图中,Tribbon看起来和它在主窗体上一样。它不如书籍或YouTube演示中的那么高。



我已经在运行Windows Xp和Delphi 2010的Win 32笔记本电脑上尝试过相同的东西,并获得完全相同的结果



这里是我机器上的样子





这里是假设在演示中看起来





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

解决方案

我终于在Delphi XE(Update 1)在启用了Aero的Win7 64上。似乎在.DFM文件中的大小设置错误,并且因为功能区不支持手动调整大小,所以无法在IDE中将其视觉修复 (尽管它在运行时正确显示)对象检查器中。它偶尔会在运行时正常显示,但它似乎也是零星的。



这是一个讨厌的错误,因为它使得不可能设计功能区。您可以添加 RibbonGroup 项目,并分配 ActionManager ,并使用结构窗格,但当然这不是一个实际的解决方案。



幸运的是,有一个很容易的解决方法,尽管这是令人讨厌的得做。 :)



我进行了两次管理以获得以下解决方法的功能,但重新启动它失败了几次,所以这是一个可能的方法(没有承诺 - 在XE中工作,在XE2更新2中一直失败):




  • 右键单击功能区并添加至少一个选项卡。

  • 右键单击IDE中的表单,然后选择以文本形式查看从上下文(弹出)菜单。

  • .dfm 文本中查找功能区控件,并更改$ code>高度从$ code> 26 ,IDE分配给$ code> 200 。 (下一步将调整它,但没关系 - 200 修复了直接的问题。)

  • 再次右键单击,选择查看为窗体功能区应正确显示。



(我在QC中针对XE2 Update 2报告,因为问题还存在 - 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 的声明中,有一个发布的属性声明:

 已发布
...
属性高度默认值TCustomRibbon.cRibbonHeight;

由于这是默认值,所以看起来任何其他值都意味着调用<$ c $上面提到的c> GetRibbonMetric 不会发生(参见上面提到的 TCustomRibbon.Create ),并且调用$ $ c的奇怪结果$ c> GetSystemMetric 导致将错误值 26 保存为其他值。威尔将更新AM中的QC。



附录:更新QC报告及其他详细信息。



附录:QC在2012年5月份报告打开,但似乎没有被解决为的XE5更新1(2014年1月检查)。


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

here is what it is suppose to look like in a 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?

解决方案

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).

这篇关于TRibbon不显示选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆