Hi,
Is there a way to change the text of a menu item after the menu has been created?
i.e:
openwindow .........
then:
BEGINMENU dy
MENUTITLE "&File"
MENUITEM "Exit",0,5000
MENUTITLE "Applications"
MENUITEM "Show details",0,5001
ENDMENU
Basically, when an item is selected in a listbox (e.g. 123.exe) how could I change
MENUITEM "Show details" to MENUITEM "Show details for 123.exe"
Also, is there a way to place a tick against a menuitem when you create the menu?
I'm sure I've done this before just can't find any reference to it.
Thanks,
Andy.
$include "windowssdk.inc"
WINDOW dy
OPENWINDOW dy,0,0,640,480,@SIZE,0,"Caption",&handler
CONTROL dy,@button,"Change Menu 1",250,30,170,25,0,10
CONTROL dy,@button,"Change Menu 2",250,60,170,25,0,11
CONTROL dy,@button,"Check",250,90,170,25,0,12
CONTROL dy,@button,"UnCheck",250,120,170,25,0,13
BEGINMENU dy
MENUTITLE "&File"
MENUITEM "Exit",0,5000
MENUTITLE "Applications"
MENUITEM "Show details",0,5001
ENDMENU
WAITUNTIL dy = 0
END
string fname
SUB handler(),int
SELECT @MESSAGE
CASE @IDCLOSEWINDOW
CloseWindow dy
CASE @IDCREATE
CENTERWINDOW dy
CASE @IDCONTROL
SELECT @CONTROLID
CASE 10
if @notifycode=0
fname="123.exe"
SetMenuText(dy,5001,"Show details for "+fname)
endif
CASE 11
if @notifycode=0
fname="456.exe"
SetMenuText(dy,5001,"Show details for "+fname)
endif
CASE 12
if @notifycode=0
CHECKMENUITEM(dy,5001,1)
endif
CASE 13
if @notifycode=0
CHECKMENUITEM(dy,5001,0)
endif
ENDSELECT
ENDSELECT
RETURN 0
ENDSUB
SUB SetMenuText(win as WINDOW,id as INT,text as STRING)
UINT hTopMenu
MENUITEMINFO info
hTopMenu = GetMenu(win.hwnd)
IF hTopMenu <> NULL /*window has a menu*/
RtlZeroMemory(info,LEN(MENUITEMINFO))
info.cbSize = LEN(MENUITEMINFO)
info.fMask = MIIM_TYPE
info.fType = MF_STRING
info.dwTypeData = text
info.cch = LEN(text)
SetMenuItemInfo(hTopMenu,id,FALSE,info)
ENDIF
RETURN
ENDSUB
Thanks Larry,
Thats great, it does change the menuitem descriptions - thanks.
Kicked myself for not remembering the CHECKMENUITEM option, guess I was looking for the word
"Tick".
Anyway, thanks!
Andy.
:)
CHECKMENUITEM was in the help file in the section on menus. ;)