How to change the items value in the main menu

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
chrisjx2002
Posts: 173
Joined: Wed Jan 06, 2010 5:39 pm
Been thanked: 2 times

How to change the items value in the main menu

Post by chrisjx2002 »

Hello,

I want to be able to change the values of the main menu items to support different languages.

If the user chooses the english one the menu will be in english. If he wants to change it, he can do it without reloading the program... It is simple to do that when defining the main menu but after I don't know how to change it. I don't find something like Windowsname.mainmenu.item1.value := 'xxx'. How to do that?

Regards

User avatar
Rathinagiri
Posts: 5295
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 183 times
Been thanked: 199 times
Contact:

Post by Rathinagiri »

Hi,

You can call any number of times 'define main menu' sequence.

Please consider this example. Created from menu.1 sample.

Code: Select all

#include "hmg.ch"

Function main()

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 400 ;
		HEIGHT 200 ;
		TITLE 'Menu Test' ;
		MAIN 

		DEFINE MAIN MENU

			POPUP 'File'

				ITEM 'Open' 		ACTION MsgInfo ('File:Open') IMAGE 'Check.Bmp' 
				ITEM 'Save' 		ACTION MsgInfo ('File:Save') IMAGE 'Free.Bmp'  
				ITEM 'Print' 		ACTION MsgInfo ('File:Print') IMAGE 'Info.Bmp'  
				ITEM 'Save As...' 	ACTION MsgInfo ('File:Save As')
				ITEM 'HMG Version' 	ACTION MsgInfo (HMGVersion())
				SEPARATOR
				ITEM 'Exit' 		ACTION MsgInfo ('File:Exit') IMAGE 'Exit.Bmp'

			END POPUP

			POPUP 'Test' 

				ITEM 'Item 1' 		ACTION MsgInfo ('Item 1')  name xxx
				ITEM 'Item 2' 		ACTION MsgInfo ('Item 2')

				POPUP 'Item 3' name test
					ITEM 'Item 3.1' 		ACTION MsgInfo ('Item 3.1') 
					ITEM 'Item 3.2' 		ACTION MsgInfo ('Item 3.2')

					POPUP 'Item 3.3'
						ITEM 'Item 3.3.1' 		ACTION MsgInfo ('Item 3.3.1')
						ITEM 'Item 3.3.2' 		ACTION MsgInfo ('Item 3.3.2')

						POPUP 'Item 3.3.3' 	

							ITEM 'Item 3.3.3.1' 		ACTION MsgInfo ('Item 3.3.3.1')
							ITEM 'Item 3.3.3.2' 		ACTION MsgInfo ('Item 3.3.3.2')
							ITEM 'Item 3.3.3.3' 		ACTION MsgInfo ('Item 3.3.3.3')
							ITEM 'Item 3.3.3.4' 		ACTION MsgInfo ('Item 3.3.3.4')
							ITEM 'Item 3.3.3.5' 		ACTION MsgInfo ('Item 3.3.3.5')
							ITEM 'Item 3.3.3.6' 		ACTION MsgInfo ('Item 3.3.3.6')  

						END POPUP

						ITEM 'Item 3.3.4' 		ACTION MsgInfo ('Item 3.3.4')

					END POPUP

				END POPUP

				ITEM 'Item 4' 		ACTION MsgInfo ('Item 4')

			END POPUP

			POPUP 'Help'

				ITEM 'About' 		ACTION MsgInfo ('Help:ABout')

			END POPUP

		END MENU

		DEFINE CONTEXT MENU
			ITEM 'Item 1' 		ACTION MsgInfo ('Item 1') 
			ITEM 'Item 2' 		ACTION MsgInfo ('Item 2')
			SEPARATOR
			ITEM 'Item 3' 		ACTION MsgInfo ('Item 3')
		END MENU
		
		define button new
		   row 100
		   col 10
		   caption 'Click'
		   action newmenu()
		end button

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return


function newmenu
		DEFINE MAIN MENU of Form_1

			POPUP 'File1'

				ITEM 'Open1' 		ACTION MsgInfo ('File:Open') IMAGE 'Check.Bmp' 
				ITEM 'Save1' 		ACTION MsgInfo ('File:Save') IMAGE 'Free.Bmp'  
				ITEM 'Print1' 		ACTION MsgInfo ('File:Print') IMAGE 'Info.Bmp'  
				ITEM 'Save As...1' 	ACTION MsgInfo ('File:Save As')
				ITEM 'HMG Version1' 	ACTION MsgInfo (HMGVersion())
				SEPARATOR
				ITEM 'Exit1' 		ACTION MsgInfo ('File:Exit') IMAGE 'Exit.Bmp'

			END POPUP

			POPUP 'Test1' 

				ITEM 'Item 11' 		ACTION MsgInfo ('Item 1')  name xxx
				ITEM 'Item 21' 		ACTION MsgInfo ('Item 2')

				POPUP 'Item 31' name test
					ITEM 'Item 3.11' 		ACTION MsgInfo ('Item 3.1') 
					ITEM 'Item 3.21' 		ACTION MsgInfo ('Item 3.2')

					POPUP 'Item 3.31'
						ITEM 'Item 3.3.11' 		ACTION MsgInfo ('Item 3.3.1')
						ITEM 'Item 3.3.21' 		ACTION MsgInfo ('Item 3.3.2')

						POPUP 'Item 3.3.31' 	

							ITEM 'Item 3.3.3.11' 		ACTION MsgInfo ('Item 3.3.3.1')
							ITEM 'Item 3.3.3.21' 		ACTION MsgInfo ('Item 3.3.3.2')
							ITEM 'Item 3.3.3.31' 		ACTION MsgInfo ('Item 3.3.3.3')
							ITEM 'Item 3.3.3.41' 		ACTION MsgInfo ('Item 3.3.3.4')
							ITEM 'Item 3.3.3.51' 		ACTION MsgInfo ('Item 3.3.3.5')
							ITEM 'Item 3.3.3.61' 		ACTION MsgInfo ('Item 3.3.3.6')  

						END POPUP

						ITEM 'Item 3.3.41' 		ACTION MsgInfo ('Item 3.3.4')

					END POPUP

				END POPUP

				ITEM 'Item 41' 		ACTION MsgInfo ('Item 4')

			END POPUP

			POPUP 'Help1'

				ITEM 'About1' 		ACTION MsgInfo ('Help:ABout')

			END POPUP

		END MENU


return nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

chrisjx2002
Posts: 173
Joined: Wed Jan 06, 2010 5:39 pm
Been thanked: 2 times

Post by chrisjx2002 »

Super! Thanks a lot. I didn't know that it was possible to redefine the main menu like this.

Regards

User avatar
Rathinagiri
Posts: 5295
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 183 times
Been thanked: 199 times
Contact:

Post by Rathinagiri »

Me too!

You are welcome!
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply