I believe there is a problem with the deletion of separator lines in submenus when the Menu, MenuName, Delete command is used to delete the menu and all submenus. Apparently, separator lines in the submenus are not deleted. The code below (based on Example #2) demonstrates the problem. After launching the script, press #z to show the menu and notice the residual separator lines at the bottom of the submenu.
Code: Select all
#NoEnv
; Create the popup menu by adding some items to it.
Start:
Menu, MyMenu, Add, Item1, MenuHandler
Menu, MyMenu, Add, Item2, MenuHandler
Menu, MyMenu, Add ; Add a separator line.
; Create another menu destined to become a submenu of the above menu.
Menu, Submenu1, Add, Item1, MenuHandler
Menu, Submenu1, Add
Menu, Submenu1, Add, Item2, MenuHandler
Menu, Submenu1, Add
Menu, Submenu1, Add, Item3, MenuHandler
; Create a submenu in the first menu (a right-arrow indicator). When the user selects it, the second menu is displayed.
Menu, MyMenu, Add, My Submenu, :Submenu1
Menu, MyMenu, Add ; Add a separator line below the submenu.
Menu, MyMenu, Add, Item3, MenuHandler ; Add another menu item beneath the submenu.
return ; End of script's auto-execute section.
MenuHandler:
MsgBox You selected %A_ThisMenuItem% from the menu %A_ThisMenu%.
return
#z:: ; i.e. press the Win-Z hotkey to show the menu.
; Menu, Submenu1, Delete ; With this line, separator lines in the submenu are properly deleted.
Menu, MyMenu, Delete
Gosub, Start
Menu, MyMenu, Show
return
Code: Select all
; Create the popup menu by adding some items to it.
MyMenu := Menu()
Submenu1 := Menu()
CreateMenu
CreateMenu() {
MyMenu.Add "Item 1", MenuHandler
MyMenu.Add "Item 2", MenuHandler
MyMenu.Add ; Add a separator line.
; Create another menu destined to become a submenu of the above menu.
Submenu1.Add "Item A", MenuHandler
Submenu1.Add
Submenu1.Add "Item B", MenuHandler
Submenu1.Add
Submenu1.Add "Item C", MenuHandler
; Create a submenu in the first menu (a right-arrow indicator). When the user selects it, the second menu is displayed.
MyMenu.Add "My Submenu", Submenu1
MyMenu.Add ; Add a separator line below the submenu.
MyMenu.Add "Item 3", MenuHandler ; Add another menu item beneath the submenu.
}
MenuHandler(Item, *) {
MsgBox "You selected " Item
}
#z:: ; i.e. press the Win-Z hotkey to show the menu.
{
; Submenu1.Delete ; With this line, separator lines in the submenu are properly deleted.
MyMenu.Delete
CreateMenu
MyMenu.Show
}