Is there a way to get the caption/ name/value associated with a MENUITEM?
...
MENUITEM "Level 1"
ONCLICK SayInfo("You have clicked on " + ???????) // How do I get "Level 1" returned ?
NAME L1
...
If I try SayInfo("You have clicked on " + THIS.NAME) the response is "You have clicked on L1"
What I want it to return is "You have clicked on Level 1"
Have tried multiple different this and, obviously NAME Level 1 or NAME "Level 1" will not work. Any ideas?
Zim
PS. I know that SayInfo("You have clicked on Level 1") would solve the problem here BUT I am looking to use this in a more complicated way. This example is a simple version to describe the problem....
Get MENUITEM caption name?
Moderator: Rathinagiri
Re: Get MENUITEM caption name?
To get caption from a menu item, that menu item must have a defined name, otherwise it cannot be identified.
See the code below, maybe it will be helpful.
See the code below, maybe it will be helpful.
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 (_GetMenuItemCaption( This.Name , ThisWindow.Name )) Name m1
ITEM 'Save' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) Name m2
ITEM 'Print' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) Name m3
ITEM 'Save As...' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name m4
ITEM 'HMG Version' ACTION MsgInfo (HMGVersion()) name m5
SEPARATOR
ITEM 'Exit' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name m6
END POPUP
POPUP 'Test'
ITEM 'Item 1' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name xxx
ITEM 'Item 2' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name qqq
POPUP 'Item 3' name test
ITEM 'Item 3.1' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name q1
ITEM 'Item 3.2' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name q2
POPUP 'Item 3.3'
ITEM 'Item 3.3.1' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name w1
ITEM 'Item 3.3.2' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name w2
POPUP 'Item 3.3.3'
ITEM 'Item 3.3.3.1' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name e1
ITEM 'Item 3.3.3.2' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name e2
ITEM 'Item 3.3.3.3' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name e3
ITEM 'Item 3.3.3.4' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name e4
ITEM 'Item 3.3.3.5' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name e5
ITEM 'Item 3.3.3.6' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name e6
END POPUP
ITEM 'Item 3.3.4' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name v1
END POPUP
END POPUP
ITEM 'Item 4' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name ppp
END POPUP
POPUP 'Help'
ITEM 'About' ACTION MsgInfo (_GetMenuItemCaption( This.Name , ThisWindow.Name )) name hlpab
END POPUP
END MENU
END WINDOW
CENTER WINDOW Form_1
ACTIVATE WINDOW Form_1
Return
*------------------------------------------------------------------------------*
Function _GetMenuItemCaption ( ItemName , FormName )
*------------------------------------------------------------------------------*
Local x, cCaption := ""
x := GetControlIndex ( ItemName , FormName )
IF x > 0 .AND. ( _HMG_SYSDATA [1] [ x ] == "MENU" .OR. _HMG_SYSDATA [1] [ x ] == "POPUP" )
cCaption := _HMG_SYSDATA [ 33 ] [ x ]
EndIf
Return cCaption
Re: Get MENUITEM caption name?
Ah, looks like that is in Harbour MiniGUI Extended which I am nowhere near being competent enough to use.
Thank you for responding, I appreciate your time! Even when there is no simple answer, it helps me learn.
Thank you for responding, I appreciate your time! Even when there is no simple answer, it helps me learn.