New - 17.01 - easy way to add buttons to ribbon using mapbasic
Add and remove buttons to any Pro ribbon tab using Create or Alter ButtonPad statements
Although there is no new version of mapbasic shipped for 17.01, you can still use this new syntax via the "run command" statement.
For MapInfoPro x64 this is the relevant syntax being changed. Other syntax for Create ButtonPad and Alter ButtonPad is ignored when using the Ribbon Interface.
Create ButtonPad { title_string } As
button_definition [ button_definition ... ]
[ Title title_string ]
[ Tab tab_name | tab_caption ]
[ { Show | Hide } ]
button_definition
{ PushButton | ToggleButton | ToolButton }
Calling { procedure | menu_code | OLE methodname | DDE server, topic }
[ ID button_id ]
[ Small | ExtraSmall | Large Icon icon_code [ File file_spec ] ]
[ Cursor cursor_code [ File file_spec ] ]
[ DrawMode dm_code ]
[ HelpMsg msg ]
[ ModifierKeys { On | Off } ]
[ { Enable | Disable } ]
[ { Check | Uncheck } ]
icon_code can now use Uri syntax for the File token
e.g.:
icon -1 file "pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/openTable_16x16.png"
Alter ButtonPad { current_title }
[ Add button_definition [ button_definition ... ] ]
[ Remove { handler_num | ID button_id } [ , ... ] ]
[ Title new_title ]
[ Tab tab_name | tab_caption ]
[ { Show | Hide } ]
[ Destroy ]
button_definition
{ PushButton | ToggleButton | ToolButton }
Calling { procedure | menu_code | OLE methodname | DDE server, topic }
[ ID button_id ]
[ Small | ExtraSmall | Large Icon icon_code [ File file_spec ] ]
[ Cursor cursor_code [ File file_spec ] ]
[ DrawMode dm_code ]
[ HelpMsg msg ]
[ ModifierKeys { On | Off } ]
[ { Enable | Disable } ]
[ { Check | Uncheck } ]
Icon Code can now use Uri syntax for the File token
e.g.:
icon -1 file "pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/openTable_16x16.png"
Syntax changes:
Added the “tab” keyword to Create and Alter ButtonPad MapBasic statements
if altering an existing Ribbon Tab, the tab name is the programmatic name of the tab (e.g.: "TabMap"), not the Ribbon Tab caption.
NOTE: To get the NAMES of existing Ribbon controls, build and run the ProSampleAddin provided with MapBasic and use its Dump Object Model tool.
(\MapBasic\Samples\RIBBONINTERFACE\DotNet\ProSampleAddIn)
If creating a New Tab you can specify both the Tab Name and its Caption by separating them with the pipe symbol; (e.g.: "MyNewTab | MyNewCaption"
Added [Small | ExtraSmall | Large] tokens to button_definition clause for Icons
Added ability to use Uri syntax to specify button icon using file token
Users can now create new tabs or tab groups on existing ribbon tabs
Users can also add buttons to existing tab groups (Previously ‘Legacy’ Tab was automatically assumed).
When altering a ButtonPad to remove a button, users must specify the Name of the Tab where ButtonPad exists in order to remove it.
Example:
alter buttonpad "MapFile" add pushbutton calling HelloRibbon Small icon 46 Title "Hello" helpmsg "help on hello" Tab "TabMap"
Example:
Alter ButtonPad "PushButtons" Add PushButton small
icon -1 file "pack://application:,,,/MapInfo.StyleResources;component/Images/Mapping/openTable_16x16.png"
HelpMsg "\nUriIcon"
ID 4
Calling button1_handler
Title "Using Uri"
Tab "PushButtonTab"
Show
Create ButtonPad <BPad> As Default
Syntax requires adding the Tab Name to reset custom buttonpad
e.g.: Create ButtonPad "PushButtons" as Default Tab "PushButtonTab"