Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Designer Bars and Menu Customization
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Designer Bars and Menu Customization

 Post Reply Post Reply
Author
Message
chrisc0 View Drop Down
Newbie
Newbie


Joined: 15 April 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote chrisc0 Quote  Post ReplyReply Direct Link To This Post Topic: Designer Bars and Menu Customization
    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?
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
chrisc0 View Drop Down
Newbie
Newbie


Joined: 15 April 2009
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote chrisc0 Quote  Post ReplyReply Direct Link To This Post 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?
 
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.