MapInfo Pro Developers User Group

Expand all | Collapse all

Creating new ribbon interface

  • 1.  Creating new ribbon interface

    Posted 01-06-2020 15:40
    I am trying to create a customized ribbon interface and when run the mbx, I see this. Can anyone help me? I have to run the program again then it works.



    Also, when close the mbx tool, I received multiple messages. Here are the 2 of the 5 messages i received it.


    This is the program when I ran and once I unload the tool.


    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------


  • 2.  RE: Creating new ribbon interface

    Posted 01-07-2020 09:05
    Edited by Peter Horsbøll Møller 01-07-2020 09:05

    Hi Michel

    It looks like you are using the RIBBONLib to build your ribbon interface.

    Can you make sure that you have used the most recent version from Github? You can download a zip file with the most recent files from here: mbLibrary on Github.

    Use the Clone or Download button to download the zip file.

    Once you have set your project to use the latest versions, recompile your own source files and link your MapBasic project.

    If you are still getting errors, let us know and we can look into the specific issues.


    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 3.  RE: Creating new ribbon interface

    Posted 01-07-2020 10:14
    Peter,

    Thank you. I did not use the latest version. You are such a help. I have been looking at your code and it makes perfectly sense. Do you know by any chance how to customize shortcut when right click with the mouse on the map window? I have been using version 12.5 so it is such different now. Here the code I have been using. Hopefully you will be able to help me.

    ' Recreate right click Map Menu
    Create Menu "MapperShortcut" ID 17 As "(-",
        "Open Doq's For Boundary" Calling OPEN_DOQ_FOR_BND,
        "Open Hypso For Boundary" Calling OPEN_HYP_FOR_BND,
        "Open Drg's For Boundary" Calling OPEN_DRG_FOR_BND,
        "Open Og Layers For Boundary" Calling OPEN_OGS_FOR_BND,
        "Open Fema For Boundary" Calling OPEN_FEMA_FOR_BND,
        "Open Nwi For Boundary" Calling OPEN_NWI_FOR_BND,
        "Open Soil For Boundary" Calling OPEN_SOIL_FOR_BND,
        "Open Geology For Boundary" Calling OPEN_GEO_FOR_BND,
        "(-", "Clear Cosmetic Layer" Calling M_MAP_CLEAR_COSMETIC,
        "(-", "Previous View" Calling M_MAP_PREVIOUS,
        "View Entire Layer..." Calling M_MAP_ENTIRE_LAYER

    Thanks

    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------



  • 4.  RE: Creating new ribbon interface

    Posted 01-08-2020 08:11
    You can use the RibbonLib to create the context menus too.

    Here is a basic example showing how to add a single control to the Mapper Context menu:
    nCtrlIdx = RBNCntxtMenuAddMenuItem(MenuId_MapperShortcut, "mapCntxtOpenDoqs", "Open Doq's For Boundary", "")
    If nCtrlIdx > 0 Then
       'Create & Set the button tooltip
       Call RBNControlSetToolTipIdx(nCtrlIdx, PRGIGetApplicationName(), "Open Doq's For Boundary", "")
       'Set the button icon
       Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_SMALL, ""
                   , pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/openTable_16x16.png)
       Call RBNControlSetLeftMarginIdx(nCtrlIdx, 0)
       'Set Custom MapBasic Handle to the button
       Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "OPEN_DOQ_FOR_BND")
    End If

    If you want to create your own version of the Mapper context menu, you can use this example to clear most of the controls from the Mapper Context menu:
    nNumCtrls = RBNCntxtMenuCount(MenuId_MapperShortcut)
    For i = 2 To nNumCtrls
       Call RBNCntxtMenuRemoveControlItem(MenuId_MapperShortcut, RBN_ELEMENT_REMOVE_LAST)
    Next


    I seem to recall that you can't clear it completely. That will recreate it from scratch. So you will need to keep at least one of the existing menu items in the menu. In my example above I remove all menu items but the first.

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 5.  RE: Creating new ribbon interface

    Posted 01-08-2020 14:22
    Peter,

    It is fantastic. It is working great.

    Thanks

    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------



  • 6.  RE: Creating new ribbon interface

    Posted 01-09-2020 15:04
    Edited by Michel Li 01-09-2020 17:09
    Peter,

    The right click shortcut works fine in MapInfo 2019 but it looks like it does not work correctly in Version 17.

    sample of the code:

    nCtrlIdx = RBNCntxtMenuAddMenuItem(MenuId_MapperShortcut, "mapCntxtOpenDoqs", "Open Topo's For Boundary", "")
    If nCtrlIdx > 0 Then
         'Create & Set the button tooltip'Create & Set the button tooltip
         Call RBNControlSetToolTipIdx(nCtrlIdx, "Open Topo's", "Open Topo's For Boundary", "")
         'Set the button icon
         Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_SMALL, "", PATH_IMAGES & "topo.png" )
         Call RBNControlSetLeftMarginIdx(nCtrlIdx, 0)
        'Set Custom MapBasic Handle to the button
        Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "OPEN_DRG_FOR_BND")

    When compiled and ran, I see this when I right clicked on the map window. What do you think the problem can be?





  • 7.  RE: Creating new ribbon interface

    Posted 01-10-2020 03:17
    Hi Michel

    I'm not sure what I'm looking at in the images above.
    I can see the Map Mini Toolbar just below the controls of the ribbon circled in yellow.
    What are you trying to highlight with the three yellow lines across the screen?

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 8.  RE: Creating new ribbon interface

    Posted 01-10-2020 13:00
    Peter,

    What I mean is when I right click on the map window with version 2019, it works fine. When I use version 17 and right click on the map window, it crashes and I see white background.

    Thanks

    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------



  • 9.  RE: Creating new ribbon interface

    Posted 01-13-2020 06:03
    That's not good, Michel.

    Did you compile and link all the modules with MapBasic 17.0 or MapBasic v2019?

    Weird, that it crashes on right-click on not on load.

    Can you try to comment out the change to the Mapper Context menu and recompile/link the tool and run it again in v17? Does it work now in MapInfo Pro 17.0?

    If you are adding multiple controls/menu items, can you try to enable these one or two at a time to try to identify which is causing the problem?

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 10.  RE: Creating new ribbon interface

    Posted 01-15-2020 14:46
    Peter,

    When remote desktop, it is where the right click for shortcut does not work well. It looks like it is zooming in so close. I don't know how to fix this type of problem. Do you have any idea?

    Thanks
    Michel

    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------



  • 11.  RE: Creating new ribbon interface

    Posted 01-16-2020 02:48
    Hi Michel

    Does it work fine if you don't change the context menu?
    If it does, try to remove most of your custom controls to understand if it's a specific control that you add that makes Pro misbehave.

    If it fails with the standard context menu, I think we need to get Tech Support involved.

    Could the problem be related to a big difference in screen sizes between your computer and the computer you are connecting to using remote desktop?

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 12.  RE: Creating new ribbon interface

    Posted 01-16-2020 15:31
    Peter,

    I found the cause. The icon image was too big so when right clicked, one of the image icon covers the whole screen. It might be due to Windows 7 version because Windows 10 works just fine.

    ------------------------------
    Michel Li
    Programmer
    GEOSEARCH LLP
    Austin TX
    ------------------------------



  • 13.  RE: Creating new ribbon interface

    Posted 01-17-2020 02:15
    Good catch, Michel!

    Yeah, for context menus the recommended image size is 16 x 16 pixels

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------