Print Page | Close Window

Dynamically changing 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=9475
Printed Date: 17 June 2025 at 9:20am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Dynamically changing menus
Posted By: Neil
Subject: Dynamically changing menus
Date Posted: 02 February 2008 at 5:41am
I am creating a VB6 application which consists of several different document types (e.g. database table viewer, word processing etc), and each of these documents requires a different menu set.

I need to be able to change the entire menu (not just elements of an existing menu), when the 'active document' changes. Does anyone know how I may implement this using the CommandBars control?.





Replies:
Posted By: corpcon
Date Posted: 04 February 2008 at 1:19am
This is a taste of what I use. It determines what primary form is open and displays only the appropriate menus (in my case, I have 4 or 5 primary forms of which require certain menu items - using your example, one primary form would be the main form for word processing). You may need to reference the provided Codejock samples if this doesn't make sense, because that's how I figured this out. Note that the "gcs" variables are global constant strings that contain the names of the primary forms.
 
In the Update event ...
 
Dim sThisForm As String
If Screen.ActiveForm Is Nothing Then Exit Sub
sThisForm = Screen.ActiveForm.Name
 
' Viewing a menu header (in this case the "Open" menu header) ...
ControlOpenMenu.Visible = IIf(sThisForm = gcsRegistrationForm Or sThisForm = gcsBarcodeForm Or sThisForm = gcsMainOrderForm, False, True)
 
' Viewing specific menu items ...
Select Case Control.Id
    Case ID_OPEN_SETUP: Control.Visible = IIf(sThisForm = gcsSetupForm, False, True)
 
' More detail based on circumstance ...
    Case ID_OPEN_DYMOSETUP
            If sThisForm = gcsSetupForm Then
                Control.Visible = True
                Control.Enabled = IIf(gbUseDymoAddressLabels = True, True, False)
            Else
                Control.Visible = False
            End If


Posted By: Neil
Date Posted: 04 February 2008 at 9:42pm
Thanks corpcon



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