Yes, I took the easy way and just showed the very basic PushButton, or Button Control.
You can of course also create a ToolButton which oinly needs a few more settings, such as DrawMode and Icon.
Button Control
This is the basics of the Button Control ignoring the ToolTips and Icons as that's the same for both types but they need to use different procedures, see under ToolButton Control:
'Now add a button to the group's controls collection with a name, caption and enumerated ControlTypemtsBtn = MICtrlCollAddStrStrInt(mtsGroupControlColl, "btnConnectDots", "Connect The Dots", ControlType_Button)'Set command to the buttonCall SetRbnBtnCtrlCallingHandler(mtsBtn, "ConnectTheDots")
ToolButton Control
The ToolButton control gets added using the same function but the ControlType must be different:
mtsBtnTool = MICtrlCollAddStrStrInt(mtsGroupControlColl, "btnConnectDots", "Connect The Dots", ControlType_ToolButton)It also needs a handler but that needs to reach to a "tool" click and be able to fetch the coordinates from the clicks
Call SetRbnToolBtnCtrlCallingHandler(mtsBtnTool, "ConnectTheDotsUsingTool")
And then we need to specify a DrawMode for the ToolButton:
Call SetRbnToolBtnCtrlDrawMode(mtsBtnTool, DM_CUSTOM_POLYLINE)
And we should specify a cursor. Notice that I convert it to string as it requires a string value which also can hold the File in case of a custom cursor:
Call SetRbnToolBtnCtrlCursor(mtsBtnTool, Str$(MI_CURSOR_CROSS))
And here is the specific procedure calls to use for ToolTips and Icons:
tsToolTip = New_MapInfoRibbonToolTip()Call SetMIRbnToolTipToolTipDescription(tsToolTip, "Connect The Dots Tool")Call SetMIRbnToolTipToolTipText(tsToolTip, "Creates a polygon or polyline by drawing")Call SetMIRbnToolTipToolTipDisabledText(tsToolTip, "Make sure to select records from a layer")Call SetRbnToolBtnCtrlToolTip(mtsBtnTool, tsToolTip)Call SetRbnToolBtnCtrlSmallIcon(mtsBtnTool, New_Uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Spatial/segmenting_16x16.png", 0))Call SetRbnToolBtnCtrlLargeIcon(mtsBtnTool, New_Uri("pack://application:,,,/MapInfo.StyleResources;component/Images/Spatial/segmenting_32x32.png", 0))Call SetRbnToolBtnCtrlIsLarge(mtsBtnTool, TRUE)