Thank you for your answers. They gave me tips I needed to achieve my goal. I got first taste too how to use Peter's mbLibrary. My final Ribbon part of my program is following:
Include "mapbasic.def"
Include "IMapInfoPro.def"
Include "Enums.def"
Include "Menu.def"
Include "Icons.def"
Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\RIBBONLib.def"
Declare Sub main
Declare Sub Ruumikuju_vahetamine ' When Ribbon button is clicked this external procedure is activated.
Declare Sub AddIn_About
Declare Sub AddIn_Help
Declare Sub AddIn_DefaultCommand
Declare Sub EndHandler
Declare Function AddIn_DefaultCommandText() As String
Declare Function AddIn_Description() As String
Declare Function AddIn_ImageUri()As String
Declare Function AddIn_Name()As String
Declare Function AddIn_Version()As String
'*******************************************************************
Sub main
Dim nCtrlIdx As Integer
Dim sTabName As Logical
Dim LargeIconLocation As String
Dim SmallIconLocation As String
'Procedure in RibbonLib, which gives the names and captions in Ribbon
'Call RBNLoop
If not RBNTabExists( "Tühi1") then
nCtrlIdx = RBNAddTab("Tühi1", "PTA lisad", "")
nCtrlIdx = RBNTabAddGroup("TabSisestus","Sisestustööriista lisad","Tühi1")
nCtrlIdx = RBNGroupAddButton("TabRuumikujuVahetamine", "Ruumikuju vahetamine", "", "Tühi1", "TabSisestus")
Call RBNControlSetToolTipIdx(nCtrlIdx,"Siin on tutvustav tekst tööriista kohta","","")
LargeIconLocation=ApplicationDirectory$() & "Images\" & "Ruumik_asendamine_32.ico" 'My icon is located in local disc in picture file format not in dll.
SmallIconLocation=ApplicationDirectory$() & "Images\" & "Ruumik_asendamine_16_ver2.ico"
Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_LARGE,SmallIconLocation,LargeIconLocation)
Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "Ruumikuju_vahetamine")
Else
nCtrlIdx = RBNTabAddGroup("TabSisestus","Sisestustööriista lisad","Tühi1")
nCtrlIdx = RBNGroupAddButton("TabRuumikujuVahetamine", "Ruumikuju vahetamine", "", "Tühi1", "TabSisestus")
Call RBNControlSetToolTipIdx(nCtrlIdx,"Siin on tutvustav tekst tööriista kohta","","")
LargeIconLocation=ApplicationDirectory$() & "Images\" & "Ruumik_asendamine_32.ico"
SmallIconLocation=ApplicationDirectory$() & "Images\" & "Ruumik_asendamine_16_ver2.ico"
Call RBNControlSetIconsIdx(nCtrlIdx, CONTROL_SIZE_LARGE,SmallIconLocation,LargeIconLocation)
Call RBNControlSetCustomMBXHandlerIdx(nCtrlIdx, "Ruumikuju_vahetamine")
End If
End Sub
'*************************************************
Sub AddIn_About
'*************************************************
Note "See tööriist võimaldab asendada korraga ühe või mitu sisestustööriista ruumikuju mingil kasutaja enda MapInfo kihil oleva ühe või mitme ruumikujuga."
End Sub
'*************************************************
Function AddIn_DefaultCommandText() as string
'*************************************************
AddIn_DefaultCommandText = "Käivita tööriist"
End Function
'*************************************************
Function AddIn_Description() as String
'*************************************************
' Note "This describes the tool in use"
AddIn_Description="See tööriist võimaldab asendada korraga ühe või mitu sisestustööriista ruumikuju mingil kasutaja enda MapInfo kihil oleva ühe või mitme ruumikujuga."
End function
'*************************************************
Sub AddIn_DefaultCommand
'*************************************************
call Ruumikuju_vahetamine
End Sub
'*************************************************
Function AddIn_ImageUri() As String
'*************************************************
AddIn_ImageUri = ApplicationDirectory$() & "/Images/" & "Ruumik_asendamine_16_ver2.ico"
End Function
'*************************************************
Sub AddIn_Help
'*************************************************
Note "1. Vali sisestustööriista kiht, mille ruumikuju soovid muuta."+Chr$(13)+"2. Vali enda kiht, kus asuvad uued ruumikujud."+Chr$(13)+"3. Vali seoseväljad kahe tabeli vahel."+Chr$(13)+"4. Käivita ""OK"" või katkesta ""Cancel""."
End Sub
'*************************************************
Function AddIn_Name() As String
'*************************************************
AddIn_Name = "Ruumikuju vahetamine"
End Function
'*************************************************
Function AddIn_Version() As String
'*************************************************
AddIn_Version = "1.0"
End Function
'*************************************************
Sub EndHandler
'*************************************************
'Call the EndHandler from the RibbonLib which will remove elements added to the ribbon
Call RBNEndHandler
End Sub
------------------------------
Asko Poder
Knowledge Community Shared Account
------------------------------
Original Message:
Sent: 01-12-2022 08:25
From: William Wemple
Subject: Add new button under existing Ribbon Tab
Hi Asko:
if you want to do this without using Peter's RibbonLib nearly all our built-in tools create controls under existing Ribbon Tabs.
If you look at the MB source code under \Samples\MAPBASIC\Disperse (for one example), you will see how this is done through these extensibility methods in MapBasic. Peter's RibbonLib is just a wrapper around these Extensibility methods defined in IMapInfoPro.def.
If you want to do this solely in MapBasic (in version 2100) without calling Extensibility methods as Peter mentions, the \Samples\MAPBASIC\CreateRibbon sample code provided with MapBasic 21 has an example for creating every control type available in the Ribbon using Create Ribbon, Set Ribbon, RibbonInfo, etc.
------------------------------
Bill Wemple
Principal Software Engineer, Quality Management
Precisely, Inc
precisely.com
Original Message:
Sent: 01-11-2022 10:25
From: Asko Poder
Subject: Add new button under existing Ribbon Tab
Hi
Newby MapBasic coder problem :). How can I add new Ribbon Button Control under existing Ribbon Tab and under existing Ribbon Tab Group (if it is present in MapInfo). This existing Ribbon Tab (called "PTA lisad") is created for my other MapBasic tool using document "How to Customize the MapInfo Pro Ribbon Interface".
I try to use P. H. Møller's mbLibrary to achieve this goal.To begin with I guess I have to check whether Ribbon Tab called "PTA lisad" is present in Ribbon Tab Collection. According to mbLibrary RibbonLib-->RBNLoop the real name for "PTA Lisad" is "Tühi1" (attachment "RibbonElements"). Next I try to call function RBNTabExists from RibbonLib. Now I'm stuck with error (attachment "mb_error_on_compilation") then I compile this .mb. I'm using MapInfo 2019.3.
Include "mapbasic.def"
Include "IMapInfoPro.def"
Include "Enums.def"
Include "Menu.def"
Include "Icons.def"
Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\RIBBONLib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\RibbonElements.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\ARRAYLib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\ConfigFileLib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\FILELib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\RESSTRNGLib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\DEBUGLib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\ERRORLib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\STRINGLib.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\defaults.def"
'Include "C:\My_documents\MapBasic\mbLibrary\mbLibrary-master\WINAPI 1522.def"
Declare Sub main
Declare Sub EndHandler
'Declare Function RBNTabExists(ByVal sTabName As String) as Logical
Global mapinfoApplication as This
Global Ribbon as This
Global RibbonTabColl as This
Global RibbonTab as This
Global ribbonGroupsColl as This
Global ribbonGroup as This
Global groupControlColl as This
Global button1 as This
Global button1ToolTip as This
Global rbnTabItem As This
Global CheckTabExist As Logical
'Global TabName As String
Sub main
Dim kQuery, x, z as String
Dim NumOfTables, i, j, nArrayIndex as Integer
Dim k as Logical
'TabName="Tühi1"
Call RegisterUriParser(New_GenericUriParser(1), "pack", -1)
mapinfoApplication = SystemInfo(SYS_INFO_IMAPINFOAPPLICATION)
Ribbon = GetRibbon(mapinfoApplication)
RibbonTabColl = GetTabsColl(Ribbon)
Call RBNTabExists("Tühi1")
If CheckTabExist then
Print "Tab exists"
Else
Print "Tab does not exist"
End If
End Sub
'*************************************************
Sub EndHandler
'*************************************************
dim bRet as logical
'bRet = MICtrlCollRemove(RibbonTabColl, RibbonTab)
'bRet = MICtrlCollRemove(ribbonGroupsColl, button1)
'bRet = MICtrlCollRemove(ribbonGroup, button1)
mapinfoApplication = NULL_PTR
Ribbon = NULL_PTR
RibbonTabColl = NULL_PTR
RibbonTab = NULL_PTR
ribbonGroupsColl = NULL_PTR
ribbonGroup= NULL_PTR
groupControlColl= NULL_PTR
button1= NULL_PTR
button1ToolTip= NULL_PTR
End Sub
----------------------------------------------------------------------------
Thanks in advance
Asko Põder
Estonian Agriculture and Food Board
------------------------------
Asko Poder
Knowledge Community Shared Account
------------------------------