Print Page | Close Window

Designer Bars and Menu Customization

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=14035
Printed Date: 07 October 2024 at 2:33am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Designer Bars and Menu Customization
Posted By: chrisc0
Subject: Designer Bars and Menu Customization
Date Posted: 15 April 2009 at 11:57pm
I have a menu created using the Designer that is loaded with LoadDesignerBars. I now want to add a menu item in the program and have that item appear in the Commands tab of the Customize window so that I can add it to a toolbar. I can make this work if the whole menu system is created in code, but if I use LoadDesignerBars, the added menu item does not appear in the Commands list of the Customize window.
 
Here is an example. I take the Designer sample project (for VB6) and modify it so that the form load event now reads:
 
Private Sub Form_Load()
 
    'Begin Modification
    'for adding a menu item
    Dim thisControl As CommandBarControl
    Dim myControl As CommandBarControl
    'End Modification
 
    CommandBarsGlobalSettings.App = App
   
    Me.Left = GetSetting(App.Title, "Settings", "MainLeft", Me.Left)
    Me.Top = GetSetting(App.Title, "Settings", "MainTop", Me.Top)
    Me.Width = GetSetting(App.Title, "Settings", "MainWidth", Me.Width)
    Me.Height = GetSetting(App.Title, "Settings", "MainHeight", Me.Height)
   
    CommandBars.LoadDesignerBars
    CommandBars.LoadCommandBars "Codejock Software ActiveX Demos", App.Title, "Layout"
   
    'Begin Modification
     'create a new menu item and set category
    Set thisControl = CommandBars.FindControl(xtpControlButton, ID_FILE_OPEN, , True)
    Set myControl = thisControl.Controls.Add(xtpControlButton, 400, "&Temp")
    myControl.Category = "TempCat"
   'End Modification
 
   
End Sub
I run the modified project,  right click in an empty part of the menu bar, select Customize and then click on the Commands tab. I expect there to be a new category TempCat in the categories list and I also expect Temp to appear in the command list, but these items are not present.
 
Can anybody tell me what is wrong with my code?
 



Replies:
Posted By: Oleg
Date Posted: 16 April 2009 at 1:35am
Hi,
 
You have modify DesignerControls property - add all controls you need here.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: chrisc0
Date Posted: 16 April 2009 at 11:07am
Thanks Oleg.
 
I changed the code to:
 
    Set myControl = CommandBars.DesignerControls.Add(xtpControlButton, 400, "&Temp")
    myControl.Category = "TempCat"
    thisControl.Controls.AddControl myControl
 
and now the items appear in the Customize Commands list, but the Temp button does not appear on the menu bar.
 
If the I change the code to
 
    Set myControl = thisControl.Controls.Add(xtpControlButton, 400, "&Temp")
    myControl.Category = "TempCat"
    CommandBars.DesignerControls.AddControl myControl
Temp appears in the menu bar, but not in the Customize Commands list.
 
How do I get Temp to appear on the menu bar and the Customize Commands list?
 


Posted By: Oleg
Date Posted: 17 April 2009 at 1:58am

Hi,

When you call AddControl  you remove it from previous CommandBar.
 
Add it to designerControls and use Copy method to copy it to MenuBar.
 
or just add same control twice 
CommandBars.DesignerControls.Add(xtpControlButton, 400, "&Temp")
thisControl.Controls.Add(xtpControlButton, 400, "&Temp")


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net