-
Переименование OpenReality меню
Дата: Апрель 20th, 2009 Neill Комментарии (9)[lang_ru]
В свое время меня очень заинтересовал плагин от NeoReel. Как всем известно, созданные утилиты помещаются в отдельный пункт главного меню Open Reality, но NeoReel переименовал этот пункт. Я решил проделать тот же трюк и получилось.
[/lang_ru]
[lang_en]
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.
[/lang_en]
[lang_ru]Мой вариант переименования заключается в следующем. В MoBu запускается плагин-менеджер. Пример такого плагина можно найти в Samples к OpenReality SDK в директории [/lang_ru]
[lang_en]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[/lang_en]
\miscellaneous\custommanager_template[lang_ru]Идея такая – находим хэндл MoBu окна, получаем хэндл на главное меню и переименовываем нужный нам пункт меню. Кстати подпункты также можно настроить под себя с помощью WinAPI.[/lang_ru]
[lang_en]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.[/lang_en]1) [lang_ru]получение билдеровского окна[/lang_ru][lang_en]Getting Modu’s window[/lang_en]
[lang_ru]Алгоритм нахождения нужного окна пришлось расположить не в вызове FBCreate, а в событие EventIdle. Дело в том, что в момент инициализации менеджера, интерфейс Mobu еще не до конца инициализирован.[/lang_ru]
[lang_en]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.[/lang_en]1
2
3
4
5
6
7FBSystem lSystem;
lSystem.OnUIIdle.Add( this, (FBCallback) &ToolManager::EventIdle );
...
if (mFirstLoad) {
EnumWindows( EnumProc, 0 );
mFirstLoad = false;
}2) [lang_ru]пишем обработчик поиска окна, где в случае успеха, получаем хэндл на главное меню и переименовываем Open Reality.[/lang_ru][lang_en]write handler search box, which if successful, get a handle of the main menu and re-name Open Reality.[/lang_en]
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;
}[lang_ru]Вот такой трюк, удачи![/lang_ru][lang_en]Here’s a trick, good luck![/lang_en]
MotionBuilder C++, Plugin, SDK, Tool, Win329 Responses to “Переименование OpenReality меню”
-
tistatos Март 15th, 2010 at 16:54
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 Март 17th, 2010 at 13:02
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 Март 17th, 2010 at 15:24
wow, thank you!
-
tistatos Март 17th, 2010 at 15:29
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 Март 17th, 2010 at 17:21
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…
Добавить комментарий
-


Свежие комментарии