VCL Ribbon MDI Fix

Disclaimer: I wrote the VCL Ribbon implementation in Delphi 2009. At the time there was no scope for MDI support in the Ribbon however the number of posts about this issue made me look into fixing it. Today I set aside some time to look at a solution and I now present this solution.

The MDI Ribbon bug is evident when your application is a MDI application and the MDI Children are maximized. The screen capture below shows this bug.

VCL Ribbon MDI Bug

VCL Ribbon MDI Bug

The fix is to drop a new component onto the Form with the Ribbon on it. Then you just need to set the Ribbon property to be the TRibbon component on the form, that is all that needs to be done.

The screen shot below shows the component at design time.

VCL Ribbon MDI Bug Fix

VCL Ribbon MDI Bug Fix

When you toggle the Enable MDI Fix check box, you need to restore and maximum a MDI Child form. For real use, you wouldn’t want to disable it anyway.

Various screen captures of the demo application with the fix active.

Fixed Ribbon MDI Bug

Fixed Ribbon MDI Bug

Fixed Ribbon MDI Bug

Fixed Ribbon MDI Bug

Fixed Ribbon MDI Bug

Fixed Ribbon MDI Bug

 

Downloading the Fix

You can download the component and demo application from my site. I may also put the fix on CodeCentral in future.

Ribbon VCL MDI Bug Fix Download

To install the component into the IDE, open the RibbonMDIFix2010.dpk file in Delphi 2010 (should also work, but is untested). In the project manager, select the Install command. Make sure the path to the RibbonMDIFix.pas unit is on your library path so that the compiler can find the file when compiling your application.

 

Further Ribbon Details

If you search for my QualityCentral entries on the Ribbon, most of the issues I raise I also provide the workaround for. Most are simple changes that can be done by copying the Ribbon units into your project folder. IIRC none are interface breaking (I’ve saved those).

 

Performance issue with MDI Applications using the TActionManager framework

There is also an issue with the MDI “detection” when a TActionMainMenuBar component (and descendants) are used in an application. This is actually a bug that was raised with Borland/CodeGear support several years ago. When you have an action that calls GetActiveMDIChild you may see processor usage increase significantly. On the Window group in the application feature throughout this post you’ll see the Close button. This is the TWindowClose standard MDI action. This actions update handler calls ActiveMDIChild. If you are running an MDI application that utilises TActionManager CPU usage will increase because of this. This occurs because of the Window Hook installed for menu processing. It handles the WM_MDIGETACTIVE message, so if an action is calling that method, the window hook is also processing it.

My solution (which also uses a window hook) avoids increasing CPU usage unnecessarily by listening to more specific MDI messages. There is no need to listen to the WM_MDIGETACTIVE (that I can see).

7 Comments

  1. Delphichem says:

    Thanks Jeremy for the great work, but it will be great to get ribbon’s fix for Right to left bidimode.

  2. Delphichem says:

    Thanks Jeremy for the great work, but it would be great to get ribbon’s fix for right to left bidirectional mode.

  3. Gregor says:

    Hi,

    Thanks for the component I use in some of my applications. Do you to plan to add contextual tabs in the next release, like :
    http://www.prof-uis.com/elegant-ribbon/tech-support/feature-articles/contextual-tabs-in-ribbon-ui.aspx ?

    Thanks.

  4. Francesco Balzani says:

    Thanks Jeremy, great work. All others ribbon components, like TMS or DevX shows the restore/minimize button on the right. Will you implement this one?

  5. Olaf says:

    Jeremy,

    while you’re at it, could you please take a look at “Using keyboard shortcuts does not work properly if the ribbon is minimized”:
    http://qc.embarcadero.com/wc/qcmain.aspx?v=69039

    As I prefer to use the keyboard instead of the mouse I would be great to have a fix for this.

    Thanks for your efforts and regards,
    Olaf

  6. Francesco Balzani says:

    Hi Jeremy, i don’t know how (if is possible) to center the button (image and caption) into the group.
    This problem occur when the ImageList size is less then 32 px. I use imageList 24×24. In this case
    seems to be left aligned.

    Thank’s in advace

  7. JED says:

    @Delphichem – RE: bidi > Changes to support right to left mode is extensive (I’ve done many but base Action Manager code changes are also required) and something that Embarcadero is responsible for.
    @Gregor – RE: Context Tabs > My version of ribbons supports context tabs. I am not responsible for maintaining the controls that ship with the product so you should ask Embarcadero about that.
    @Francesco Balzani – RE: Restore/Max buttons > It is possible to emulate these buttons. You could overlay a new TActionToolbar control in the place where the buttons would show. If I have some time I will look at providing the solution but no promises.
    @Olaf – RE: QC Bug > I’ve had a look at this report and unfortunately it isn’t fixable without interface changes. It is a tricky issue.
    @Francesco Balzani – RE: Layout > Please send me some screenshots of what you are trying to do and I will see if I can help out further.