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