What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » HELP - CreatePopupMenu sub-menus?

HELP - CreatePopupMenu sub-menus?
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. Huh?  HELP - CreatePopupMenu sub-menus?
Javascript code:
var MF_CHECKED = 0x8;
var MF_APPEND = 0x100;
var MF_GRAYED = 0x1;
var MF_SEPARATOR = 0x800;
var MF_STRING = 0x0;
// don't need the rest...
var MCOWMnu = Interop.Call("user32", "CreatePopupMenu");
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_GRAYED, 0, "Normal");
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_CHECKED, 0, "Checked");
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_SEPARATOR, 0, 0);
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_STRING, 0, "Disabled");

But is there a way to make a sub-menu?

quote:
Originally posted by MSDN
MF_POPUP: Specifies that the menu item opens a drop-down menu or submenu. The uIDNewItem parameter specifies a handle to the drop-down menu or submenu. This flag is used to add a menu name to a menu bar, or a menu item that opens a submenu to a drop-down menu, submenu, or shortcut menu.
Does that open a menu, close a menu, insert an existing menu or what?

EDIT: seems that MF_POPUP is 0x10, but now what?

This post was edited on 10-08-2009 at 07:17 PM by whiz.
10-08-2009 07:07 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: HELP - CreatePopupMenu sub-menus?
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>


.txt File Attachment: Menu.js.txt (27.96 KB)
This file has been downloaded 160 time(s).
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
10-08-2009 07:36 PM
Profile E-Mail PM Web Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: HELP - CreatePopupMenu sub-menus?
Sounds good, thanks!  :P
10-08-2009 07:48 PM
Profile E-Mail PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
35 / Male / Flag
Joined: Aug 2006
RE: HELP - CreatePopupMenu sub-menus?
I lost my example from the RPG script I was making (ages ago), but if you want to do it without the class, goto MSDN and take a look at the"Remarks section".

So create a new menu (different var name obvoiusly), and then append a new item to the main menu, but pass the MF_POPUP param and pass it the handle to the new menu.

If that makes sense lol.

I think you have to finish the popup menu before "attaching" it to the main menu though.
<Eljay> "Problems encountered: shit blew up" :zippy:
10-08-2009 07:54 PM
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: HELP - CreatePopupMenu sub-menus?
That's better - I'll use that.

Javascript code:
var MCOWMnu = Interop.Call("user32", "CreatePopupMenu");
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_STRING, 0, "Normal");
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_CHECKED, 0, "Checked");
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_SEPARATOR, 0, 0);
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_GRAYED, 0, "Disabled");
var MCOWSubMnu = Interop.Call("user32", "CreatePopupMenu");
Interop.Call("user32", "AppendMenuW", MCOWSubMnu, MF_STRING, 0, "Sub-option");
Interop.Call("user32", "AppendMenuW", MCOWMnu, MF_POPUP, MCOWSubMnu, "Sub-menu");

It works!  :P

This post was edited on 10-09-2009 at 06:14 PM by whiz.
10-09-2009 06:08 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On