Print Page | Close Window

intelligent menus

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=987
Printed Date: 10 May 2024 at 1:11pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: intelligent menus
Posted By: dajv
Subject: intelligent menus
Date Posted: 27 July 2004 at 11:30pm
Hello,

I'm trying to set menu items to only appear when recently used... as far as I can tell, one sets this by setting the visibility property to "visible if recently used". I've set this for some menu items but it seems to have no effect. What could i be doing wrong?

I also wonder how to set this programmatically? There doesnt seem to be a way, e.g.
Set ControlFile = CommandBars.ActiveMenuBar.Controls.Add(xtpControlPopup, 0, "&File")
With ControlFile.CommandBar.Controls
    Set Control = .Add(xtpControlButton, ID_FILE_NEW, "&New Database...")
    Control.Visibility = "some value resembling recently used"
End With

The visibility property only allows true and false.

Any advice would be appreciated



Replies:
Posted By: SuperMario
Date Posted: 28 July 2004 at 7:10am
Use the AddHiddenCommand method to specify that a menu item to appear hidden.  
This adds the specified command as a hidden command, i.e. an infrequently used command. 
The command will not be displayed in popup menus until the user clicks on the "expand menu"
chevron button or after a short delay when ShowFullAfterDelay is true.

CommandBars.Options.AlwaysShowFullMenus = False
CommandBars.Options.AddHiddenCommand (ID_FILE_SAVE)
CommandBars.Options.AddHiddenCommand (ID_FILE_CLOSE)
CommandBars.Options.AddHiddenCommand (ID_FILE_SAVE_AS)

To hide the control so the user can not see it, use Visible = False


Posted By: dajv
Date Posted: 28 July 2004 at 11:22pm
Thanks for your reply.

Are there any advantages/disadvantages of using a xcb "xtreme command bars designer" file over programmatically creating the menus? That is, other than the initial creation of the menus (i think both are time consuming and probably incur the same amount of time), are tehre any drawbacks of either method?



Posted By: dajv
Date Posted: 29 July 2004 at 7:23pm
I'm having trouble setting commandbar control attributes at run time... I have a command button whos event handler does the following:

1) Private Sub Command1_Click()
2)     Dim ctrl As CommandBarControl
3)     Dim ctrl1 As CommandBarControl
4)     Set ctrl = CommandBars.DesignerControls.Find(, ID_VIEW_STATUSBAR)
5)     ctrl.Caption = "&Status Bar... X"
6)     Set ctrl1 = CommandBars.DesignerControls.Find(, ID_VIEW_STATUSBAR)
7) End sub


As you can see, im using designer controls (at the moment at least). After this has run, the command bar control (a menu item with caption "&Status Bar...") is not updated to read "&Status Bar... X", however stepping through the code i can see that after line 6 ctrl1.Caption DOES equal "&Status Bar... X".

The curious thing is that if i do Control.Caption = "blah" in the CommandBars_Update() or CommandBars_Execute() subs, the menu bar IS updated.

Obviously I will need to make modifications to the menu outside of these subs, so am I doing something wrong?


Posted By: SuperMario
Date Posted: 29 July 2004 at 9:32pm

The DesignerControls collection of commands only holds commands that are displayed in the "Commands" tab of the Add\remove buttons customize dialog.  This collection is designed to hold all of your applicatio's controls so the user can add\remove them as needed. 

You need to change the caption of the control in CommandBars.ActiveMenuBar or CommandBars(2).FindControl or CommandBars(2).Controls.Find.  FYI: CommandBars(1) is the ActiveMenubar, CommandBars(2) is the first toolbar added, etc...

1) Private Sub Command1_Click()
2)    Dim ctrl As CommandBarControl
3     Set ctrl = CommandBars.ActiveMenuBar.FindControl(, ID_VIEW_STATUSBAR)
4     ctrl.Caption = "&Status Bar... X"
5 End sub



Posted By: dajv
Date Posted: 29 July 2004 at 10:40pm
Thanks SuperMario :)



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