ExpressBars and Visual Form Inheritance
I found a problem when using Visual Form Inheritance with ExpressBars. The inherited forms do not show the MainMenu and Toolbar at all, it simply show empty Docking place. To my surprise, when I searched the Knowledge Base, I found out that ExpressBars does not fully support Delphi‘s visual form inheritance !! In ExpressBars, the toolbars and Item Links are collection items; and unfortunately Delphi‘s form inheritance does not support collection. Collections are simply copied and thus creates many difficulties and impact ExpressBars for a proper implementation in visual form inheritance. The developers would have to completely redesign its class model. Wow, what a surprise !!
I was pointless, confused how to solve this problem. However, in the Knowledge Base, there was a good article on how to perform full creation at runtime. This article gave me an idea how to accomplish it programmatically.
To create the Item Links for menus, we can simply use:
dxBarManager.MainMenuBar.LockUpdate := True; dxBarManager.MainMenuBar.ItemLinks.Add.Item := mnuFile; with TdxBarSubItem( mnuFile ).ItemLinks.Add do begin Item := mnuFilePrint; BeginGroup := True; end; dxBarManager.MainMenuBar.LockUpdate := False;
For for the Toolbar, we can use:
dxBarManager.Bars[1].LockUpdate := True; dxBarManager.Bars[1].ItemLinks.Add.Item := mnuRecNew; dxBarManager.Bars[1].ItemLinks.Add.Item := mnuRecEdit; dxBarManager.Bars[1].ItemLinks.Add.Item := mnuRecDelete; with dxBarManager.Bars[1].ItemLinks.Add do begin Item := mnuRecSave; BeginGroup := True; end; dxBarManager.Bars[1].LockUpdate := False;
Hopefully it helps 🙂