Tabs do not appear in TRIBON

I run 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 follow the example in the Marco Cantu 2009 Marketing Guide and watch YouTube demos, but my control doesn’t work as described in the book or demos.

I added two tabs by right-clicking the control. However, TRibbon looked the same as in my screenshot when I dropped it into its main form. It's not as high as in youtube books or demos.

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

this is what it looks like on my car

64 bit laptop screenshot

this is what the demo should look like

from youtube video demo

Again. When he throws it onto a form, it does not take shape and height, as I see in the demonstrations. Even when I add tabs. Did I do something wrong during the installation of Delphi 2010?

+7
source share
1 answer

I was finally able to reproduce the problem in Delphi XE (Update 1) on Win7 64 with Aero enabled. It seems that the size is not set in the .DFM file, and since Ribbon does not support manual resizing, you cannot visually fix it in the IDE (although it displays correctly at run time) or in the Object Inspector . It sometimes appears correctly at runtime, but seems to be sporadic as well.

This is an unpleasant mistake because it makes it impossible to create a Ribbon . You can add RibbonGroup elements and assign an ActionManager , as well as try and completely construct it using the Structure Pane , but of course this is not a practical solution.

Fortunately, there is a pretty simple workaround, although this is annoying. :) The strike>

I was able to execute the following workaround twice, but starting with it, it did not work several times, so its possible path (no promises - worked in XE, did not execute sequentially in XE2 Update 2):

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

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

I traced it to TCustomRibbon.GetCaptionHeight in particular

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

It seems that calling GetSystemMetrics returns something less than 26 in some Win7 configurations (although I still cannot figure out why). There are a couple of commented out lines in this method that seem to change the result, but, as I said, they were commented out.

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

Finally, think that I traced this. The TRibbon has a published property declaration:

 published ... property Height default TCustomRibbon.cRibbonHeight; 

Since this is the default value, it looks like any other value means that the GetRibbonMetric call mentioned above does not occur (see TCustomRibbon.Create mentioned TCustomRibbon.Create ), and the strange result of the GetSystemMetric call causes error 26 to be saved as "another value". Wierd; will update QC in AM.

Appendix: Updated QC report with additional information.

Appendix: The QC report was opened in May 2012, but did not seem to have been resolved with XE5 Update 1 (verified in January 2014).

+8
source

All Articles