![]() |
Designer Bars and Menu Customization |
Post Reply ![]() |
Author | |
chrisc0 ![]() Newbie ![]() Joined: 15 April 2009 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() 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?
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
You have modify DesignerControls property - add all controls you need here.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
chrisc0 ![]() Newbie ![]() Joined: 15 April 2009 Status: Offline Points: 5 |
![]() ![]() ![]() ![]() ![]() |
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?
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |