Creating Buttons MI21.1

Skip to first unread message

Hannah Dyer

Dec 9, 2022, 5:11:58 AM12/9/22
to MapInfo-L
I am a newbie to MapBasic, but have been tasked with creating our new toolbars, that we had previously in MI15, to the new version. (A very big jump between the two!)

I have managed to create the ribbon and the ribbon tab groups but cannot get a button to be created. Currently I can run the ribbon and ribbon group in the MB toolbar in MapInfo 21.1 but when creating an MBX it doesn't work. 

I have tried running some examples, but it fails on the image for the button, as we do not have access to the 'pack' for the path images. 

I am initially trying to create a simple button but am unsure what I need to include in the MBX and what I need to declare in it. 

Hopefully someone can point me in the right direction.

Many Thanks,


Peter Horsbøll Møller

Dec 9, 2022, 5:26:11 AM12/9/22

Hi Hannah


What statements are you using to create the ribbon and buttons in MapInfo Pro?


There are a few options to choose from with MapInfo Pro v2021:

  • Create/Alter Buttonpad
  • Create Ribbon
  • .NET Methods from IMapInfoPro


Maybe even try sharing a snippet of code for one of your buttons





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


From: <> On Behalf Of Hannah Dyer
Sent: Friday, 9 December 2022 11.11
To: MapInfo-L <>
Subject: [MI-L] Creating Buttons MI21.1


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
To unsubscribe from this group, go to:
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at

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
To view this discussion on the web visit

Hannah Dyer

Dec 12, 2022, 3:38:24 AM12/12/22
to MapInfo-L

I have managed to get a button now but still difficulties with it being where its required. The end result will be several ribbons, so getting the buttons to form on the right ribbon will be essential. 

Include "icons.def"

Declare Sub Main
'Declare Sub button_prompt
Declare Sub Run_NPUs

Dim sFile as String

Sub Main

Create Ribbon Tab "TAB_MapStore" Caption "Map Store"

Create    ButtonPad "Background Maps" As PushButton
                Icon MI_ICON_OPEN_FILE
                Calling run_NPU
                HelpMsg "NPU Maps\nNPUs"
    End Sub

Sub Run_NPU

Open Table "\WMP_NPU" Interactive
Sfile = "WMP_NPU"
Browse* from SFile
end sub 


I cant seem to work out how to add the new button pad to the new 'Map Store' ribbon, as it creates it on a 'Legacy' Ribbon. I am assuming its a simple fix. 

Thanks for the help Peter 

Peter Horsbøll Møller

Dec 13, 2022, 2:43:33 AM12/13/22

Hi Hannah


Can you try changing your Main procedure into this:


Sub Main


     Create ButtonPad "Background Maps" As


                Icon MI_ICON_OPEN_FILE

                Calling run_NPU

                HelpMsg "NPU Maps\nNPUs"

           Tab "TAB_MapStore|Map Store"


End Sub


What you can see is that the code creates a new group called Background Maps on a new ribbon tabbed called Map Store.


You don’t need the Create Ribbon statement if you just are looking to add a number of buttons to a new or existing tab

You can read more about using the Create/Alter Buttonpad method in this thread:


You can of course also do the same through the Create Ribbon statement only.

You can find some examples here:


I hope this helps you on the way

Reply all
Reply to author
0 new messages