![]() |
Dynamically changing menus |
Post Reply ![]() |
Author | |
Neil ![]() Groupie ![]() Joined: 16 December 2007 Status: Offline Points: 40 |
![]() ![]() ![]() ![]() ![]() 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?. |
|
![]() |
|
corpcon ![]() Groupie ![]() Joined: 28 June 2007 Status: Offline Points: 70 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
|
Neil ![]() Groupie ![]() Joined: 16 December 2007 Status: Offline Points: 40 |
![]() ![]() ![]() ![]() ![]() |
Thanks corpcon
|
|
![]() |
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 |