1

I encountered yet another problem with ribbon. When I have two forms (one of them is main) and I put ribbon on both of them, they behave strangely. When I open the second form by Form2.Show;, every time I click a ribbon menu button on the second form, it loses focus and the main form gets it.

This happens at pure blank project, so what could I possibly be doing wrong?

Here is a video, just in case: Watch YT

And to be clear, the Action1 button has only Caption:='a'; code.

Martin Melka
  • 7,177
  • 16
  • 79
  • 138
  • 3
    You're only supposed to use one ribbon control in your application, and it should be on the main form. Did you read the MS guidelines for using the Fluent Interface (which you agreed to abide by during the installation of Delphi)? – Ken White Feb 10 '12 at 17:53
  • I didn't. I'm trying to look it up now, because I need a separate form (with the same design) and I can't think of a way to do it with only one ribbon (hopefully the guidelines will cover it) – Martin Melka Feb 10 '12 at 18:04
  • 1
    @Magicmaster, If you really need to switch between 2 identical forms, I would suggest you rearchitect your application to have 1 MainForm with the ribbon hosting either SubForm1 or SubForm2. SubForms could be embedded Forms, Frames or other containers like Panels or Pages. – Francesca Feb 10 '12 at 18:59
  • [Office UI Guidelines](http://msdn.microsoft.com/en-us/office/aa973809.aspx). :) Took a while to find it, I agree. – Ken White Feb 10 '12 at 19:30
  • Also, see this [SO question](http://stackoverflow.com/questions/8403323/delphi-xe-tribbon-actions-always-send-focus-to-mainform), especially the accepted answer. – Ken White Feb 10 '12 at 21:24
  • @François, the two forms aren't identical. You can think of it as the main form being a pictures gallery with some ribbon options and actions and the second form being a picture editor. – Martin Melka Feb 11 '12 at 15:42

1 Answers1

0

The ribbon control assumes that there is only one per application, and misbehaves if it is not the only control. You could try to modify the Ribbon.pas code, but it is doing some hacks that probably rely on Ribbon.Parent being Application.MainForm only.

Warren P
  • 65,725
  • 40
  • 181
  • 316