Creating Buttons MI21.1

41 views
Skip to first unread message

Hannah Dyer

unread,
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,

Hannah 
WMP

Peter Horsbøll Møller

unread,
Dec 9, 2022, 5:26:11 AM12/9/22
to mapi...@googlegroups.com

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
  • RIBBONLib

 

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

 

Thanks

Peter

 

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

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Hannah Dyer
Sent: Friday, 9 December 2022 11.11
To: MapInfo-L <mapi...@googlegroups.com>
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 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/5534ef91-985c-4817-8548-2017134bc191n%40googlegroups.com.

Hannah Dyer

unread,
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"
                Show
    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

unread,
Dec 13, 2022, 2:43:33 AM12/13/22
to mapi...@googlegroups.com

Hi Hannah

 

Can you try changing your Main procedure into this:

 

Sub Main

 

     Create ButtonPad "Background Maps" As

           PushButton

                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:

https://community.precisely.com/communities/community-home/digestviewer/viewthread?GroupId=19&MID=2124

 

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

You can find some examples here:

https://community.precisely.com/communities/community-home/digestviewer/viewthread?GroupId=67&MessageKey=d9ebd5a2-3525-4b23-9f28-976079fbde96

 

I hope this helps you on the way

Reply all
Reply to author
Forward
0 new messages