Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - Dynamically changing menus
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dynamically changing menus

 Post Reply Post Reply
Author
Message
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Topic: Dynamically changing menus
    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?.


Back to Top
corpcon View Drop Down
Groupie
Groupie


Joined: 28 June 2007
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote corpcon Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Neil View Drop Down
Groupie
Groupie


Joined: 16 December 2007
Status: Offline
Points: 40
Post Options Post Options   Thanks (0) Thanks(0)   Quote Neil Quote  Post ReplyReply Direct Link To This Post Posted: 04 February 2008 at 9:42pm
Thanks corpcon
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.047 seconds.