RE: custom menu tear off?

Date : Tue, 4 Apr 2006 14:03:16 -0400
To : <XSI(at)Softimage.COM>
From : "Luc-Eric Rousseau" <lucer(at)Softimage.COM>
Subject : RE: custom menu tear off?
he's the thing that's missing from the explanation of SetMenu.
In Win32 samples, you'll often see code that loads a menu and does a SetMenu on the window (HWND).  When that window is destroyed, it destroys the menu, as it has taken its ownership.  However for context menus, there is no SetMenu, and a call to DestroyMenu after the TrackPopupMenu.
 
About context menu tear offs, it's logged we'll probably do that in the future.
 
------------------
Luc-Eric Rousseau
Team Leader, User Interface
Softimage|XSI
-----Original Message-----
From: owner-xsi@Softimage.COM [mailto:owner-xsi@Softimage.COM]On Behalf Of Luc-Eric Rousseau
Posted At: Tuesday, April 04, 2006 12:39 PM
Posted To: xsi
Conversation: custom menu tear off?
Subject: RE: custom menu tear off?

This code leaks a the handle for the menu (perhaps you just forgot to put the DestroyMenu?) and therefore will eventually starve XSI for resources.
 SetMenu((HWND)__g__hInstance,MyMenu);
More seriously SetMenu() takes the handle of a window, but you're passing the handle of a DLL and casting that as a HWND.  That's potentially changing the windows menu of a random window in the system, if one happens to have that same random value.  I remember mentionning in a previous thread about the animation editor, the WIN32 SetMenu call is only used to set the top menu of a WS_POPUP application window and there is no conceivable reason why one would call this function in a plug-in, since there is no such window.
 
Also, not a bug but could confuse people trying to use this sample, it's adding a menu item with ID zero, but zero is the value that is also returned when the menu is closed without selecting anything
------------------
Luc-Eric Rousseau
Team Leader, User Interface
Softimage|XSI
-----Original Message-----
From: owner-xsi@Softimage.COM [mailto:owner-xsi@Softimage.COM]On Behalf Of Andrea Padovan
Posted At: Tuesday, November 29, 2005 9:42 PM
Posted To: xsi
Conversation: custom menu tear off?
Subject: Re: custom menu tear off?

I forgot...
You could create your menu like a window and a CDH like container of it.
I had same problem and I resolved it in this way.
 
----- Original Message -----
Sent: Wednesday, November 30, 2005 11:25 AM
Subject: Re: custom menu tear off?

Hi Juan,
 
If your goal is to create your custom contextual menu inside XSI, it is very simple with C++.
 
#include <windows.h>
 
HINSTANCE __g__hInstance = NULL;
 
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
      )
{
    switch (ul_reason_for_call)
 {
  case DLL_PROCESS_ATTACH:
  case DLL_THREAD_ATTACH:
  case DLL_THREAD_DETACH:
  case DLL_PROCESS_DETACH:
  break;
    }
 
 __g__hInstance = (HINSTANCE)hModule;
    return TRUE;
}
 
// Command_Execute
Application app;
 POINT GlobalMousePosition;
 GetCursorPos(&GlobalMousePosition);
 
 HMENU MyMenu = CreatePopupMenu();
 AppendMenu(MyMenu,MF_STRING,0,"Item zero");
 AppendMenu(MyMenu,MF_STRING,1,"Item one");
 AppendMenu(MyMenu,MF_STRING,2,"Item two");
 
 SetMenu((HWND)__g__hInstance,MyMenu);
 
 int retval = TrackPopupMenuEx( MyMenu,
         TPM_RETURNCMD,
         GlobalMousePosition.x,
         GlobalMousePosition.y,
         GetForegroundWindow(),NULL);
 
 app.LogMessage(L"Global Cursor Position : ");
 app.LogMessage(CValue(GlobalMousePosition.x).GetAsText());
 app.LogMessage(CValue(GlobalMousePosition.y).GetAsText());
 
 app.LogMessage(L"Returned Value : " + CValue((long)retval).GetAsText() );
 
And you could call command for to show menu...
I don't Know in linux.
 
ããããããããããã
Andrea Padovan
 
Tool Designer @
SEGA CORPORATION
AM R&D Dept.#1 Arcade Team
AM R&D Div.
http://www.sega.co.jp/
Blr. Founder
http://www.borderliner.it
Actually located in Tokyo Japan
 
----- Original Message -----
From: "Juan Brockhaus" <Juan@glassworks.co.uk>
Sent: Tuesday, November 29, 2005 9:23 PM
Subject: custom menu tear off?

> Hi,
>
> probably this was asked before, but is it possible to create your custom
> menus as tear off menus?
> couldn't find it in the manuals.
> ...and it's still not possible to embed them into the right menus like edit,
> select, etc...?
>
> thanks,
>
> Juan
> ---
> Unsubscribe? Mail Majordomo@Softimage.COM with the following text in body:
> unsubscribe xsi

Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.