473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Addressing Menu Items

[I apologize if this is an incredibly newbie question ...]

I am looking for a way via code to access all the menu itmes on a given
form. I am looking for something like the Forms or Controls collections, but
for menu items. Is there such a thing or method? I would prefer to avoid
using the Win API but will do so if that's the only way available.

This is for a language-translation (of an existing program) where I wish to
change (English to Spanish initially) the Descriptions for all the menu
items.

Thanks in advance

Bob K.
Jan 14 '06 #1
6 4936
I have a few multilingual programs (9 languages and counting...) and use the
following technique:

item.Caption = text

Under the Tools >>> Menu Editor, just give a name to each menu item.

You can then change the caption of the item using:

FileHeader.Caption = phrase$(97)
MenuExit.Caption = phrase$(101)

I use an external ANSI text file for each language and just load each line
into a preset phrase when the language is changed on the fly.

Hope this gets you going.

I still have not found a way to support UNICODE characters in the menu
items, but spanish only requires the ANSI character set so you should be
fine.

Regards,
Tom

"Bob Kochem" <in**@minuteman-systems.com> wrote in message
news:JKfyf.788$SD3.741@trndny07...
[I apologize if this is an incredibly newbie question ...]

I am looking for a way via code to access all the menu itmes on a given
form. I am looking for something like the Forms or Controls collections,
but for menu items. Is there such a thing or method? I would prefer to
avoid using the Win API but will do so if that's the only way available.

This is for a language-translation (of an existing program) where I wish
to change (English to Spanish initially) the Descriptions for all the
menu items.

Thanks in advance
Bob K.

Jan 15 '06 #2
You can do this with the controls collection of the form.

The following code loops through all the controls on the form, checking for
the type of the control. If it comes back as "Menu", then it is a menu
control/object. In other words, if the code makes it to the Debug.Print
line, then you have found a menu item. Good luck!

Private Sub Command1_Click()
Dim ctl As VB.Control

For Each ctl In Me.Controls
If StrComp(TypeName(ctl), "Menu", vbTextCompare) = 0 Then
'Found a menu item
Debug.Print ctl.Name
End If
Next

Set ctl = Nothing
End Sub

"Bob Kochem" <in**@minuteman-systems.com> wrote in message
news:JKfyf.788$SD3.741@trndny07...
[I apologize if this is an incredibly newbie question ...]

I am looking for a way via code to access all the menu itmes on a given
form. I am looking for something like the Forms or Controls collections,
but for menu items. Is there such a thing or method? I would prefer to
avoid using the Win API but will do so if that's the only way available.

This is for a language-translation (of an existing program) where I wish
to change (English to Spanish initially) the Descriptions for all the
menu items.

Thanks in advance

Bob K.

Jan 15 '06 #3
> Private Sub Command1_Click()
Dim ctl As VB.Control

For Each ctl In Me.Controls
If StrComp(TypeName(ctl), "Menu", vbTextCompare) = 0 Then
I would use the following If-Then statement instead of the above...

If TypeOf ctl Is Menu Then

Rick

'Found a menu item
Debug.Print ctl.Name
End If
Next

Set ctl = Nothing
End Sub

Jan 15 '06 #4
Thanks to all who have replied here.

I think this gets me off and running.

I am assuming I can use a similar approach to rename all labels and other
named items on forms.

Can anyone point at a good tutorial on making programs support multiple
languages? I would like to avoid re-inventing the wheel if possible.

One more thing I am wrestling with is all the message boxes that are posted
in the program. The program's been around quite a while and now makes use of
the MsgBox in a couple hundred places. I am thinking of creating a "meta"
message box function, something like TransMsgBox, doing a global replace of
"MsgBox" with "TransMsgBox" and then having the TransMsgBox function do the
translation (somehow) for every set of arguments passed to it.

Thanks,

Bob
"Kiteman - Canada" <-d*************@shaw.ca> wrote in message
news:y_gyf.343436$ki.139988@pd7tw2no...
I have a few multilingual programs (9 languages and counting...) and use
the following technique:

item.Caption = text

Under the Tools >>> Menu Editor, just give a name to each menu item.

You can then change the caption of the item using:

FileHeader.Caption = phrase$(97)
MenuExit.Caption = phrase$(101)

I use an external ANSI text file for each language and just load each line
into a preset phrase when the language is changed on the fly.

Hope this gets you going.

I still have not found a way to support UNICODE characters in the menu
items, but spanish only requires the ANSI character set so you should be
fine.

Regards,
Tom

"Bob Kochem" <in**@minuteman-systems.com> wrote in message
news:JKfyf.788$SD3.741@trndny07...
[I apologize if this is an incredibly newbie question ...]

I am looking for a way via code to access all the menu itmes on a given
form. I am looking for something like the Forms or Controls collections,
but for menu items. Is there such a thing or method? I would prefer to
avoid using the Win API but will do so if that's the only way available.

This is for a language-translation (of an existing program) where I wish
to change (English to Spanish initially) the Descriptions for all the
menu items.

Thanks in advance
Bob K.


Jan 15 '06 #5
Point! Thanks for the tip...

Jay Taplin, MCP
Jan 15 '06 #6
Bob, take a look at my NPW9b or NPW-HA kite making programs at:
http://members.shaw.ca/kiteman/Downloads.htm

On each form I have built a Label that is large enough to contain the
translation with the greatest number of characters. The caption for the
label is set as:

Label1.Caption = Phrase$(xxx)

where "xxx" is obtained from the left three characters from the line in the
external language text file.

I did try using Resource files (websearch for "Resource files for
Localization")- it worked to some extent for my purposes, but since my
translations were being done by volunteers around the world, I couldn't let
multiple people have access to the resource file - it would bound to get
botched at some point.

A big advantage to using my external language file is that anyone can
perform a translation and plop it into the same folder - as long as it
follows my file naming convention it is automatically recognized the next
time the program is run and they can use it immediately. The only time
that I am required to do anything is if the person needs more room to fit
the extra characters that their verbose language might require. I have
found that if I allow room for the German language, that pretty much any
other language will fit well within that space.

If you require UNICODE support, you will have to use the objects from the MS
Forms 2.0 library.

If you know someone who is willing to translate my language files into
Spanish, I would appreciate it :-)
Tom

"Bob Kochem" <in**@minuteman-systems.com>
wrote in message news:b_iyf.447$Bn4.75@trndny08...

I think this gets me off and running.

I am assuming I can use a similar approach to rename all labels and other
named items on forms.

Can anyone point at a good tutorial on making programs support multiple
languages? I would like to avoid re-inventing the wheel if possible.

One more thing I am wrestling with is all the message boxes that are
posted in the program. The program's been around quite a while and now
makes use of the MsgBox in a couple hundred places. I am thinking of
creating a "meta" message box function, something like TransMsgBox, doing
a global replace of "MsgBox" with "TransMsgBox" and then having the
TransMsgBox function do the translation (somehow) for every set of
arguments passed to it.

Thanks,

Bob
Tom

"Bob Kochem" <in**@minuteman-systems.com> wrote in message
news:JKfyf.788$SD3.741@trndny07...
[I apologize if this is an incredibly newbie question ...]

I am looking for a way via code to access all the menu itmes on a given
form. I am looking for something like the Forms or Controls collections,
but for menu items. Is there such a thing or method? I would prefer to
avoid using the Win API but will do so if that's the only way available.

This is for a language-translation (of an existing program) where I wish
to change (English to Spanish initially) the Descriptions for all the
menu items.

Thanks in advance
Bob K.

Jan 15 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
1
by: Anthony | last post by:
Below is a script I found at http://javascript.internet.com/ for a cascading menu. The script works great but there is one thing that I would like modified. BecauseI am just learning javascript,...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
1
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hi, friends, I am using C#.net 2005 to create a windows application. It has menu items, such as File, etc. Under File, there are more menu items, such as New Files, Working Files, etc. Under...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.