Rearrange menu bar

We are developing bricscad plugin and up until V21 we were able to rearrange menu bar via COM interface:
IAcadPopupMenuPtr::RemoveMenuFromMenuBar();
IAcadPopupMenuPtr::InsertInMenuBar(_variant_t(popup_count));
That would translate to: remove menu item at and put it back at the end.

Starting V22 function "InsertInMenuBar" hits an error: access violation, regardles of input.

Is there any other way to rearrange menus in menu bar using COM or ObjectBrx?

Comments

  • I have further investigated the issue:
    IAcadPopupMenuPtr::RemoveMenuFromMenuBar(); actually removes popup from menu bar, but as it seems it removes it from MenuGroup as well:
    MenuGroups->MenuGroup->PopupMenus::GetCount(long *count) returns 0.

    If I reload main cui, I can find missing PopupMenu and can put it back on the menu bar.

    Another issue is, that function:
    IAcadPopupMenuPtr::InsertInMenuBar(VARIANT index); puts menu before index. That means, that menu can't be positioned to last position, once it is removed from menu bar.
  • A lisp version

    (setq Menu_Path "C:\\XXX-CAD-TOOLS\\"); Path to Menu file
    (setq Menu_Name "XXX-CAD-TOOLS"); pop menu to load
    (setq Group_Name "XXXMENU"); groupname assigned in .mnu or .mns file

    (if (menugroup menu_Name)
    (command "_MENUUNLOAD" menu_Name)
    )

    (if (> (vl-string-search "BricsCAD" (getvar 'acadver)) 0)
    (progn
    (command "MENULOAD" (strcat Menu_Path Menu_Name ".CUI"))
    (menucmd (strcat "P20=+" menu_Name ".POP1"))
    )
    (progn
    (setq cnt (vla-get-count(vla-get-menuGroups (vlax-get-acad-object))))
    (command "MENULOAD" (strcat Menu_Path Menu_Name))
    (menucmd (strcat "P" (rtos (+ cnt 1) 2 0) "=+" menu_Name ".POP1"))
    )
    )