I was very interested in the plug of NeoReel. As we all know, created tools are placed in a separate paragraph the main menu, Open Reality, but NeoReel renaming the item. I decided to do the same trick and succeeded.

mymenu

My version of change is as follows. In MoBu I add a new plugin manager. An example of such a plugin can be found in the Samples of the OpenReality SDK in the directory

\miscellaneous\custommanager_template

The idea of this – find the window handle MoBu, get handle of the main menu and re-name our menu. By the way, you can also configure the sub-menu by youself with the help of WinAPI.

1) Getting Modu’s window

The algorithm of finding the right window are not accounted for in the call FBCreate, but in the event EventIdle. The point is that at the time of initialization of the manager interface Mobu not yet fully initialized.

1
2
3
4
5
6
7
FBSystem lSystem;</p>
<p>lSystem.OnUIIdle.Add( this, (FBCallback) &ToolManager::EventIdle );</p>
<p>...</p>
<p>if (mFirstLoad) {</p>
<p>EnumWindows( EnumProc, 0 );</p>
<p>mFirstLoad = false;</p>
<p>}

2) write handler search box, which if successful, get a handle of the main menu and re-name Open Reality.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</p>
<p>BOOL CALLBACK EnumProc( HWND hwnd, LPARAM lParam )</p>
<p>{</p>
<p>char szTitle[MAX_PATH];</p>
<p>GetWindowText( hwnd, szTitle, MAX_PATH );
<p>if (strstr( szTitle, "MotionBuilder" ) != NULL)</p>
<p>{</p>
<p>//-- store motion builder window handle</p>
<p>a_gWnd = hwnd;</p>
<p>HMENU lMenu = GetMenu( hwnd );</p>
<p>if (!lMenu)</p>
<p>return true; // continue searching</p>
<p>MENUITEMINFO mii;</p>
<p>int itemsCount = GetMenuItemCount( lMenu );</p>
<p>UINT Id;</p>
<p>char szMenuString[255];</p>
<p>for (int i=0; i<br />
Id = GetMenuItemID( lMenu, i );</p>
<p>GetMenuString( lMenu, i, szMenuString, 255, MF_BYPOSITION );</p>
<p>if (strstr( szMenuString, "&Open Reality" ) != NULL )</p>
<p>{</p>
<p>mii.cbSize = sizeof( mii );</p>
<p>mii.fMask = MIIM_STRING;</p>
<p>mii.dwTypeData = szMenuString;</p>
<p>mii.cch = 255;</p>
<p>GetMenuItemInfo( lMenu, i, TRUE, &mii );</p>
<p>sprintf( szMenuString, "&My Menu" );</p>
<p>if ( SetMenuItemInfo( lMenu, i, TRUE, &mii ) == 0 )</p>
<p>{</p>
<p>printf( "error while renaming menu\n" );</p>
<p>DisplayErrorText( GetLastError() );</p>
<p>}</p>
<p>//</p>
<p>// build custom menu</p>
<p>//</p>
<p>// You could add here your own menu items</p>
<p>}</p>
<p>}</p>
<p>//-- redraw main menu bar</p>
<p>DrawMenuBar( hwnd );</p>
<p>return false;</p>
<p>}</p>
<p>return true;</p>
<p>}</p>

Here’s a trick, good luck!

Renaming OpenReality menu
Tagged on:                 

9 thoughts on “Renaming OpenReality menu

  • Monday March 15th, 2010 at 04:54 PM
    Permalink

    Hey man, i cant get this to work. i never get a handle for the menu.

  • Tuesday March 16th, 2010 at 07:24 PM
    Permalink

    Hi, I’m quite busy at the moment… I’ll check this as soon as possible.

  • Wednesday March 17th, 2010 at 01:02 PM
    Permalink

    i see, well i guess i can explain a litte more in depth :).

    so i do get a handle for the motionbuilder window but then GetMenu() just returns a 0x000000 adress. is there another way to get this menu handle perhaps?

    i was wondering what version of motionbuilder you’ve done this in.

    and i really dont understand this line:

    a_gWnd = hwnd;

  • Wednesday March 17th, 2010 at 03:24 PM
    Permalink

    wow, thank you!

  • Wednesday March 17th, 2010 at 03:29 PM
    Permalink

    hmm, you wouldn’t happen to have it for 2010?, thats what we use here..

  • Wednesday March 17th, 2010 at 05:16 PM
    Permalink

    cause 2010 is built on the Qt framework… there might be another way to access to a menu bar, which is in progress…
    You could try to do that if you would like
    1. MoBu handle you have to convert to a Qt widget
    QWidget *pWidget = QWidget::find( (WId) hwnd );
    2. When there is a way to see widget className
    const QMetaObject* metaObject = pWidget->metaObject();
    const char *className = metaObject->className();
    printf(className);
    3. By going through main widget children, search onto QMenu or QMenuBar item to get access on it
    4. These might be enough to add new menu actions

  • Wednesday March 17th, 2010 at 05:21 PM
    Permalink

    i totaly forgot about QT in 2009. thanks man!

  • Wednesday March 17th, 2010 at 05:25 PM
    Permalink

    Qt is in 2010…
    If you will have any progress with that, share it please with me if It’ll be possible for you of course…

Leave a Reply

Your email address will not be published. Required fields are marked *