remove an entry in the menu MapperShortcut

35 views
Skip to first unread message

Laurent

unread,
May 27, 2021, 8:09:06 AM5/27/21
to MapInfo-L
Hi
I use RibbonLib and I can add a new menu in the MapperShortcut
nCtrlIdx = RBNCntxtMenuInsertMenuItem(MenuId_MapperShortcut, "mapCntxt", "My menu", "", 0)
No problem
but I want to remove an existang menu, "Clear Cosmetic Layer"
I tried with 
RBNCntxtMenuRemoveControlItem
or 
RBNCntxtMenuRemoveControl
What is the sControlName of "Clear Cosmetic Layer" (Calling 810)
Thanks
Regards

Laurent

unread,
May 27, 2021, 10:53:42 AM5/27/21
to MapInfo-L
I also test this, but nothing happens

nNumCtrls = RBNCntxtMenuCount(MenuId_MapperShortcut)
For i = 2 To nNumCtrls
   Call RBNCntxtMenuRemoveControlItem(MenuId_MapperShortcut, RBN_ELEMENT_REMOVE_LAST)
Next

MapBasic 17 and Mapinfo 19.3
Thanks

Peter Horsbøll Møller

unread,
May 27, 2021, 11:51:21 AM5/27/21
to mapi...@googlegroups.com
Hi

There are some limitations to the context menus currently. You can for example not remove all items.

Have you tried hiding the menu item instead(set visibility to false)

Peter Horsbøll Møller
Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 


Den 27. maj 2021 kl. 16.53 skrev Laurent <laurent.m...@gmail.com>:



This message originated Externally. Use proper judgement and caution with attachments, links, or responses.


--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/34681691-0c64-4b1f-9df5-7452a626aba2n%40googlegroups.com.

Laurent

unread,
May 28, 2021, 4:27:57 AM5/28/21
to MapInfo-L
Hi
Thanks Peter
In RubbonLib, i do not see a function to change visibility of contex menu.
and command Alter menu do not work.
even when I leave only one menu, it doesn't work

nNumCtrls = RBNCntxtMenuCount(MenuId_MapperShortcut)
For i = 2 To nNumCtrls
   Call RBNCntxtMenuRemoveControlItem(MenuId_MapperShortcut, RBN_ELEMENT_REMOVE_LAST)
Next

Regards

Peter Horsbøll Møller

unread,
May 31, 2021, 2:19:12 AM5/31/21
to mapi...@googlegroups.com

Hi

 

Yeah, the RibbonLib is not full implementation of all the things you can do to the ribbon, unfortunately.

 

There are some methods that do come in handy though.

 

Try the following:

1. Make sure your tool has initiated the RibbonLib. You can also force this by calling RBNInitiate

 

2. Run this script to

Dim rbnCntxtMenu, rbnControlCollection, rbnElement As this

 

   'Get the specific Context menu for the Mapper

   rbnCntxtMenu = ICntxtMnusGetCntxtMnu(theContextMenus, MenuId_MapperShortcut)

   '*Get the controls collection of this context menu

   rbnControlCollection = GetICntxtMnuCtrls(rbnCntxtMenu)

   '*Remove all but one control

 

   nNumControls = GetMICtrlCollCount(rbnControlCollection)

   Print "Number of Controls on Map Context Menu: " & nNumControls

   For i = 1 To (nNumControls – 2)

      Print "Hiding Control " & (i - 1)

      rbnElement = GetMICtrlCollItemInt(rbnControlCollection, (i - 1))

      Call RBNControlSetVisibilityThs(rbnElement, FALSE)

   Next

 

This will loop through all the controls but the last two and hide them.

The trick for you is to determine which control to hide.

You could use RBNControlGetCmdIDThs To get to the CommandID for the control and compare this to the one you want to hide.

 

Also make sure you have the most recent version of the RibbonLib.

You can grab that from here: https://github.com/PeterHorsbollMoller/mbLibrary

 

Peter Horsbøll Møller

www.precisely.com

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

Laurent

unread,
Jun 2, 2021, 8:47:58 AM6/2/21
to MapInfo-L
Thanks Peter
It is ok

Regards

Reply all
Reply to author
Forward
0 new messages