DisplayHide
Displays and hides the Open-button in the Home-tab This example shows:
  • the use of the AlterControl-function to change the layout of buttons in the MapInfo-interface
  • the use of icons in imagefiles
  • the implementation of the About-window, the tooltip, the help and the icon in the Toolmanager
Include "MapBasic.def"

Declare Sub Main
Declare Sub HideOpen
Declare Sub DisplayOpen

'Ribbon SDK *************
	Declare Sub EndHandler
	Declare Method New_RibbonSDK Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Ctor_CreateInstance() as This
	Declare Method AlterControl Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias AlterControl(byval xml as string)
	Declare Method Initialize Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Initialize(ByVal p1 as This, ByVal p2 as refptr, ByVal p3 as String)
	Declare Method Unload Class "GeoAS.RibbonSDK.Addin" Lib "GeoAS.RibbonSDK.dll" Alias Unload(ByVal p1 as This)
	Declare Function AddIn_Name() As String 
	Declare Function AddIn_Description() As String 
	Declare Function AddIn_Version() As String 
	Declare Function AddIn_ImageUri() As String
	Declare Sub AddIn_About
	Declare Sub AddIn_Help

	Global myAddIn as This

'************************************************************************************
Sub Main
	myAddIn = New_RibbonSDK()
	call Initialize(myAddIn, SYSTEMINFO(SYS_INFO_IMAPINFOAPPLICATION), ApplicationName$() )
End Sub
'------------------------------------------------------------------------------------
Sub EndHandler
	call Unload(myAddIn)
End Sub

'************************************************************************************
Function AddIn_Name() As String
	AddIn_Name = "DisplayHide"
End Function
'------------------------------------------------------------------------------------
Function AddIn_Description() As String
	AddIn_Description = "Example: Displays and hides the Open-Button in the Home-Tab"
End Function
'------------------------------------------------------------------------------------
'Tooltip des Info-Buttons
'displayed only if AddIn_About also defined
Function AddIn_Version() As String
	AddIn_Version = "Version 1.0"
End Function
'------------------------------------------------------------------------------------
Function AddIn_ImageUri() As String
    Dim app_dir As String
    app_dir = ApplicationDirectory$( )
	AddIn_ImageUri = app_dir & "\Icon_AddIn.png"
End Function
'------------------------------------------------------------------------------------
'Aktion des Info-Buttons
Sub AddIn_About
	Note "Sample DisplayHide - Version 1.0"
End Sub
'------------------------------------------------------------------------------------
Sub AddIn_Help
	Note "Ribbon Sample Help"
End Sub
'************************************************************************************
Sub HideOpen
	call AlterControl("Name=""HideButton"" Enabled=""False""")
	call AlterControl("Name=""DisplayButton"" Enabled=""True""")
	call AlterControl("Name=""HomeFileOpenGallerySplitButton"" Visible=""False""")
	note "Open-Button hidden"
End Sub
'------------------------------------------------------------------------------------
Sub DisplayOpen
	call AlterControl("Name=""HideButton"" Enabled=""True""")
	call AlterControl("Name=""DisplayButton"" Enabled=""False""")
	call AlterControl("Name=""HomeFileOpenGallerySplitButton"" Visible=""True""")
	note "Open-Button displayed"
End Sub