Hi Jay
These days there are multiple ways to build your ribbon interface through MapBasic.
When I'm using the RibbonLib to build my interface, I use a structure like this:
For nCtrl = 1 To Ubound(marrFavoriteMaps)
nCtrlIdx = RBNGroupAddButton("openBaseMap" & nCtrl, marrFavoriteMaps(nCtrl).sName, "", marrAddToRibbon(nTab).sTabName, marrAddToRibbon(nTab).sGroupName)
If nCtrlIdx > 0 Then
Call RBNControlSetToolTipIdx(nCtrlIdx, PRGIGetApplicationName(), marrFavoriteMaps(nCtrl).sName, "")
Call RBNControlSetIconsIdx(nCtrlIdx, mnImageSize, "", marrFavoriteMaps(nCtrl).sImageFile)
Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "MENUFavoriteMapClicked")
nCount = Ubound(marrCommand2FavoriteMap) + 1
ReDim marrCommand2FavoriteMap(nCount)
marrCommand2FavoriteMap(nCount).nCommandId = RBNControlGetControlIDIdx(nCtrlIdx)
marrCommand2FavoriteMap(nCount).nFavoriteMapItem = nCtrl
End If
Next
The general idea is that for flexibility, the buttons are stored in an array. This makes it easy to add more, and in this case, I can let the user add as many as they would like.
To create the buttons on the ribbon, I can now loop over this array:
For nCtrl = 1 To Ubound(marrFavoriteMaps)
Every time I have added a new control/button, I get the Control ID and store this in an array too:
ReDim marrCommand2FavoriteMap(nCount)
marrCommand2FavoriteMap(nCount).nCommandId = RBNControlGetControlIDIdx(nCtrlIdx)
marrCommand2FavoriteMap(nCount).nFavoriteMapItem = nCtrl
Now my example may be a bit more complicated than your solution.
If you only have a few buttons, you can store the Control IDs in a couple of variables instead.
This is from a tool called Favorites Maps. You can find
the full source code here on GitHub.
The RibbonLib is part of
the MapBasic Library that can be found on Github too.
If you are using the new
Create Ribbon
statement that we added to MapBasic v2021, you can use the function
RibbonItemInfo
to get to the ControlID via the attribute
PROPERTY_CONTROLID
.
------------------------------
Peter Horsbøll Møller
Principal Presales Consultant | Distinguished Engineer
Precisely | Trust in Data
------------------------------
Original Message:
Sent: 06-28-2022 13:25
From: Jay Russell
Subject: CustomMBXHandler with parameters?
Does anyone have tricks to allow passing of a parameter to buttons created in the new ribbon interface?
For example if I had a button to add a red or blue feature to a map based on Splitbutton. I would share everything in the code besides the style of the new feature.
Something similar to how it was done with the 32 bit buttons discussed here or another method:
Making a Button in mapinfo with conditional functionGeographic Information Systems Stack Exchange | remove preview |
apple-touch-icon@2.png?v=54e3ab1edcf3" width="200" height="200"> | Making a Button in mapinfo with conditional function | Thanks for contributing an answer to Geographic Information Systems Stack Exchange! Please be sure to answer the question. Provide details and share your research! Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. | View this on Geographic Information Systems Stack Exchange > |
|
|
------------------------------
Jay Russell
CENTERPOINT ENERGY RESOURCES
Houston TX
------------------------------