'this program will test adding stuff to the backstage
'this is for 64-bit MI 12.5.1, which has ribbon interface
'programmed in MapBasic 12.5.1 under windows 7
'New York State Department of Health, Center for Environmental Health
'Feb 20, 2015
'create a simpler version of the code so that demonstrate need for CREATE MENU to correct handler functioning
'*****************************************************
'if I do not put the full path, mapbasic may grab an older version of these DEF files
include "C:\Program Files (x86)\MapInfo\MapBasic12\MENU.DEF"
include "C:\Program Files (x86)\MapInfo\MapBasic12\MAPBASIC.DEF"
include "C:\Program Files (x86)\MapInfo\MapBasic12\ICONS.DEF"
include "C:\Program Files (x86)\MapInfo\MapBasic12\IMapInfoPro.def"
include "C:\Program Files (x86)\MapInfo\MapBasic12\Enums.def"
declare sub main
declare sub dosomething
sub main
dim mapinfoApplication, mybackstage, mybackstagecontrols, mybackstagetabcontrols, mybackstagetab,
mynewtab, mynewbuttonintab as this
'check if we have the ribbon interface before we try to do something with it
if SystemInfo(SYS_INFO_MAPINFO_INTERFACE) = MIINTERFACE_RIBBON then 'check if have ribbon interface before we do this
print "We have detected the ribbon interface"
'get the Mapinfo application
mapinfoApplication = SystemInfo(SYS_INFO_IMAPINFOAPPLICATION)
'get the backstage
mybackstage = GetRibbonBackStage(mapinfoApplication)
'get the backstage controls
mybackstagecontrols=GetRbnBackStageCtrls(mybackstage)
'use the controls to insert a tab - goes in the blue column to the left
mynewtab=MICtrlCollInsertIntStrStrInt(mybackstagecontrols,1,"newtab","tab@1",ControlType_BackStageTabItem)
'get the controls for the new tab
mybackstagetabcontrols=GetIBackStageTabItemCtrls(mynewtab)
'use the controls to add a new ribbon button
mynewbuttonintab=MICtrlCollAddStrStrInt(mybackstagetabcontrols,"newbutton","my ribbon button",1) 'adds a new ribbon control button
'add a handler to the ribbon button
call SetRbnBtnCtrlCallingHandler(mynewbuttonintab, "dosomething") 'you need also to create the legacy menu to add the subroutine as a handler
end if 'if have ribbon interface
'MUST HAVE LEGACY MENU FOR HANDLERS TO WORK. You do not need to display it, however.
create menu "&testMenu" as
"Do it" calling dosomething
end sub
sub dosomething
note "you have clicked on the button"
end sub