Sylvania
asked on
Adding menu items at run-time
I want a SIMPLE, EASY, and CLEAN way to add menu items at run-time.
I have the menu "Languages" that will contains a variable number of items, depending on the number of languages set by the program.
So, let say this number is set to 3 (English, French and Spanish), I want the program to add these 3 languages as menu-items at run time.
thanks!
I have the menu "Languages" that will contains a variable number of items, depending on the number of languages set by the program.
So, let say this number is set to 3 (English, French and Spanish), I want the program to add these 3 languages as menu-items at run time.
thanks!
ASKER
Yes, I had that in tought, but I want to handle an infinite languages possibility... altough I know there is not such a number of 'em down there! lol
Let say I just want to know the clean way to do the job, without hidding anything; just ADDING menu-items at run-time.
thanks!
Let say I just want to know the clean way to do the job, without hidding anything; just ADDING menu-items at run-time.
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The possibilities for doing are almost infinite.
Something simple, like:
Private Sub LoadLanguages()
Dim vLanguages As Variant
Dim iMenu As Integer
vLanguages = Array("English", "French", "Spanish", "German", "Italian")
For iMenu = LBound(vLanguages) To UBound(vLanguages)
If iMenu > LBound(vLanguages) Then
Load mnuLanguages(iMenu)
End If
mnuLanguages(iMenu).Captio n = vLanguages(iMenu)
mnuLanguages(iMenu).Visibl e = True
Next iMenu
End Sub
You could add each language to the array as needed.
You could also use databases and tables.
When using the Load statement, the new menu items will not be visible, so you need .Visible = True
Something simple, like:
Private Sub LoadLanguages()
Dim vLanguages As Variant
Dim iMenu As Integer
vLanguages = Array("English", "French", "Spanish", "German", "Italian")
For iMenu = LBound(vLanguages) To UBound(vLanguages)
If iMenu > LBound(vLanguages) Then
Load mnuLanguages(iMenu)
End If
mnuLanguages(iMenu).Captio
mnuLanguages(iMenu).Visibl
Next iMenu
End Sub
You could add each language to the array as needed.
You could also use databases and tables.
When using the Load statement, the new menu items will not be visible, so you need .Visible = True
ASKER
Thanks to you too, The learned one!
I just can't believe it was this simple!
With all the people saying to use api, and other stuff... the old LOAD was the key! lol
thanks pals!
I just can't believe it was this simple!
With all the people saying to use api, and other stuff... the old LOAD was the key! lol
thanks pals!
Load mnuLanguage(1)
mnuLanguage(1).Caption = "French"
mnuLanguage(1).Visible = True
Load mnuLanguage(2)
mnuLanguage(2).Caption = "Spanish"
mnuLanguage(2).Visible = True
This could become a more complicated routine, but is this what you want?