You create a submenu with CreatePopupMenu, add items to it and then pass the handle to AppendMenuW to add it to your main menu.
However, if you prefer to avoid all this hassle, you can simply go and get the Menu class I made for Countdown Live. The only required change is that you must change this line:
Javascript code:
var subclass = MsgPlus.CreateWnd('Interfaces\\WndSubclass.xml', 'WndSubclass', 2);
to your own subclass creation code.
Example usage:
Javascript code:
// Menu callback
var MenuCallback = function(ItemId) {
Debug.Trace("Item "+ItemId+" was clicked");
};
// Create main menu
var MainMenu = new Menu(MenuCallback);
MainMenu.AddMenuItem("ItemOne", "Hello world!");
MainMenu.AddMenuItem("ItemTwo", "Lorem ipsum");
// Create and add a submenu
var SubMenu = MainMenu.CreateSubMenu();
SubMenu.AddMenuItem("SubitemOne", "Sub item 1");
SubMenu.AddMenuItem("SubitemTwo", "Sub item 2");
MainMenu.AddSubMenu(SubMenu, "A sub menu");
// Open the menu on the current cursor position
MainMenu.Open();
Example subclass window code:
XML code:
<?xml version="1.0" encoding="UTF-16"?>
<Interfaces xmlns="urn:msgplus:interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:msgplus:interface PlusInterface.xsd">
<!-- SUBCLASS WINDOW -->
<Window Id="WndSubclass" Version="1">
<Attributes>
<ShowInTaskbar>false</ShowInTaskbar>
</Attributes>
<Position Width="0" Height="0"/>
<DialogTmpl/>
</Window>
</Interfaces>