-
Renaming OpenReality menu
Posted on 20 April 2009 Neill 9 commentsI 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.
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_templateThe 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
7FBSystem lSystem;
lSystem.OnUIIdle.Add( this, (FBCallback) &ToolManager::EventIdle );
...
if (mFirstLoad) {
EnumWindows( EnumProc, 0 );
mFirstLoad = false;
}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
45
46
47
48
49
50
51
52
53
54BOOL CALLBACK EnumProc( HWND hwnd, LPARAM lParam )
{
char szTitle[MAX_PATH];
GetWindowText( hwnd, szTitle, MAX_PATH );</em>
if (strstr( szTitle, "MotionBuilder" ) != NULL)
{
//-- store motion builder window handle
a_gWnd = hwnd;
HMENU lMenu = GetMenu( hwnd );
if (!lMenu)
return true; // continue searching
MENUITEMINFO mii;
int itemsCount = GetMenuItemCount( lMenu );
UINT Id;
char szMenuString[255];
for (int i=0; i<itemsCount; i++) {
Id = GetMenuItemID( lMenu, i );
GetMenuString( lMenu, i, szMenuString, 255, MF_BYPOSITION );
if (strstr( szMenuString, "&Open Reality" ) != NULL )
{
mii.cbSize = sizeof( mii );
mii.fMask = MIIM_STRING;
mii.dwTypeData = szMenuString;
mii.cch = 255;
GetMenuItemInfo( lMenu, i, TRUE, &mii );
sprintf( szMenuString, "&My Menu" );
if ( SetMenuItemInfo( lMenu, i, TRUE, &mii ) == 0 )
{
printf( "error while renaming menu\n" );
DisplayErrorText( GetLastError() );
}
//
// build custom menu
//
// You could add here your own menu items
}
}
//-- redraw main menu bar
DrawMenuBar( hwnd );
return false;
}
return true;
}Here’s a trick, good luck!
MotionBuilder C++, Plugin, SDK, Tool, Win329 Responses to “Renaming OpenReality menu”
-
tistatos 15 March 2010 at 4:54 PM
Hey man, i cant get this to work. i never get a handle for the menu.
-
Hi, I’m quite busy at the moment… I’ll check this as soon as possible.
-
tistatos 17 March 2010 at 1:02 PM
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 0×000000 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;
-
Hi, I have prepared special plugin for your purpose… try it – http://neill3d.com/menedzher-menyu-dlya-mobu
-
tistatos 17 March 2010 at 3:24 PM
wow, thank you!
-
tistatos 17 March 2010 at 3:29 PM
hmm, you wouldn’t happen to have it for 2010?, thats what we use here..
-
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 -
tistatos 17 March 2010 at 5:21 PM
i totaly forgot about QT in 2009. thanks man!
-
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
You must be logged in to post a comment.
-


English
Russian
Recent Comments