Code: Select all
#NoEnv
Menu, CtxMenu, Add, Start, MenuHandler
Menu, CtxMenu, Add, Exit, GuiClose
HMENU := MenuGetHandle("CtxMenu")
Gui, Show, w400 h400, Right-Click ContextMenu
Return
GuiClose:
ExitApp
GuiContextMenu:
NewName := "Start"
Menu, CtxMenu, Rename, Start, %NewName%
; If !DllCall("ModifyMenu", "Ptr", HMENU, "UInt", 0, "UInt", 0x0400, "UIntP", Dummy, "Str", NewName, "UInt")
; MsgBox, 16, %A_ThisLabel%, ModifyMenu failed with Error %A_LAstError%!
Menu, CtxMenu, Show
Return
MenuHandler:
MenuItem := A_ThisMenuItem
MsgBox, 0, %A_ThisLabel%, You chose %MenuItem% from the menu!
Return
Code: Select all
---------------------------
H6062862.ahk
---------------------------
Error: Rename failed (name too long?).
Specifically: Start
Line#
043: Menu,CtxMenu,Add,Start,MenuHandler
044: Menu,CtxMenu,Add,Exit,GuiClose
045: HMENU := MenuGetHandle("CtxMenu")
046: Gui,Show,w400 h400,Right-Click ContextMenu
047: Return
050: ExitApp
053: NewName := "Start"
---> 054: Menu,CtxMenu,Rename,Start,%NewName%
057: Menu,CtxMenu,Show
058: Return
061: MenuItem := A_ThisMenuItem
062: MsgBox,0,%A_ThisLabel%,You chose %MenuItem% from the menu!
063: Return
064: Exit
065: Exit
The current thread will exit.
---------------------------
OK
---------------------------
Edit:
Think I found the bug in script_menu.cpp -> RenameItem():
Code: Select all
if (*aNewName)
{
// Names must be unique only within each menu:
for (UserMenuItem *mi = mFirstMenuItem; mi; mi = mi->mNextMenuItem)
if (!lstrcmpi(mi->mName, aNewName)) // Match found (case insensitive).
return FAIL; // Caller should display an error message.