MapInfo Pro Developers User Group

Expand all | Collapse all

Alter tool tip text for existing buttons

  • 1.  Alter tool tip text for existing buttons

    Posted 12-20-2019 15:55
    I'd like to add some custom text to one of the default tools on the mini-toolbar.

    I found an example of how to add a new tool with a custom tool tip but not how to modify the existing mini-toolbar.

    Specifically I'd like to add an additional message to the Ruler tool tip.  I am using MapInfo 19 and  Mapbasic 16 until Mapbasic 19 is available.

    Thanks,
    Jay Russell

    ------------------------------
    Jay Russell
    Sr. Technical Consultant
    CENTERPOINT ENERGY RESOURCES
    Houston TX
    ------------------------------


  • 2.  RE: Alter tool tip text for existing buttons

    Posted 12-23-2019 03:55
    Hi Jay

    You can do this through the Keyboard Shortcut tool that you can find on the Backstage under Options.

    In the example below, I have added the text highlighted in blue

    This text will be shown for the Ruler tool where ever it exists; in the Map Mini Toolbar and on the MAP tab

    Let me know if you prefer to do this via MapBasic


    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 3.  RE: Alter tool tip text for existing buttons

    Posted 01-02-2020 07:48
    Peter:

    Thanks for the tip about the Backstage options.​  I would need to change the setting through MapBasic since I'm updating the tooltip as our custom tool library loads for 200+ users.  Is there a way to distribute user options enterprise wide during installation (i.e.  Backstage options, custom tool registrations, etc.)?

    Jay

    ------------------------------
    Jay Russell
    Sr. Technical Consultant
    CENTERPOINT ENERGY RESOURCES
    Houston TX
    ------------------------------



  • 4.  RE: Alter tool tip text for existing buttons

    Posted 01-07-2020 08:52
      |   view attached
    Hi Jay

    He is a basic example of how to find the right control and change the tooltip for that control using MapBasic.

    The example below contains two loops. The outer loop loops over the Stack- and possible WrapPanels of the Map Mini Toolbar. The inner loop loops through the controls ion each of these panels to find the Measure/Ruler Tool.

    	nNumCntrls = GetMICtrlCollCount(theMapMTBControlsColl)
    	For i = 0 To (nNumCntrls - 1)
    		rbnControlItem	= GetMICtrlCollItemInt(theMapMTBControlsColl, i)
    
    		sName		= GetMICtrlName(rbnControlItem)
    		nCntrlType	= GetMICtrlCtrlType(rbnControlItem)
    		sCaption		= GetMICtrlCaption(rbnControlItem)
    		Print "      Map MiniTool Bar Control " & i & " is named '" & sName & "' but shown as '" & sCaption & "' and Control Type is " & nCntrlType & " (" & RBNControlGetTypeName(nCntrlType) & ")"
    
    		If nCntrlType In (ControlType_StackPanel, ControlType_WrapPanel) Then
    			rbnStackPanelControlsColl	= GetIStackPanelCtrls(rbnControlItem)
    			nNumStackPanelCtrls			= GetMICtrlCollCount(rbnStackPanelControlsColl)
    
    			For l = 0 To (nNumStackPanelCtrls - 1)
    				rbnStackPanelControlItem	= GetMICtrlCollItemInt(rbnStackPanelControlsColl, l)
    
    				nCntrlType	= GetMICtrlCtrlType(rbnStackPanelControlItem)
    				sName		= GetMICtrlName(rbnStackPanelControlItem)
    				sCaption		= GetMICtrlCaption(rbnStackPanelControlItem)
    				Print "         Stack-/WrapPanel Control " & l & " is named '" & sName & "' but shown as '" & sCaption & "' and Control Type is " & nCntrlType & " (" & RBNControlGetTypeName(nCntrlType) & ")"
    
    				If sName = "MeasureButton" Then
    					rbnControlToolTip = New_MapInfoRibbonToolTip()
    					Call SetMIRbnToolTipToolTipText (rbnControlToolTip, "The Ruler tool lets you measure one or more distances in the map.")
    					Call SetMIRbnToolTipToolTipDescription (rbnControlToolTip, "Ruler Tool")
    					Call SetMIRbnToolTipToolTipDisabledText (rbnControlToolTip, "Activate a Map Window to use the Ruler tool")
    					Call SetMIRbnToolTipShowHelpText (rbnControlToolTip, TRUE)
    
    					Call SetRbnBtnCtrlToolTip(rbnStackPanelControlItem, rbnControlToolTip)
    					
    					Exit Sub	
    				End If
    			Next
    		End If
    	Next​

    You can, of course, leave out the Print statements in your final application. They are only used to see which elements you are looping thru.

    I have included a full example application that you can compile and run. Also, note that the example above doesn't show all the necessary include and Dim statements

    Let me know if this raises any questions

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------

    Attachment(s)

    zip
    ModifyTooltip.zip   1K 1 version


  • 5.  RE: Alter tool tip text for existing buttons

    Posted 01-07-2020 08:55

    PS: As for distributing user options and settings during installation, that might be a bit tricker. Most of these settings are user-specific and there saved to the user profile, in the file system as well as in the registry.

    If the installation is done by the user, you can copy files across and also add certain settings to the registry. This could, for example, be wrapped into a bat file.



    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 6.  RE: Alter tool tip text for existing buttons

    Posted 01-02-2020 08:42

    gerencia-itssa@hotmail.com">

    Hi,

     

    I am having a problem updating a temp table.

    If the table is in the map (visible or not), I get this message error:

     

    Excepción no controlada del tipo 'System.AccessViolationException' en MapInfo.CoreEngine.Wrapper.dll

    Información adicional: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

     

     

    If the table IS NOT in the map, the update runs perfectly!

     

    Please I need help!

     

    Here is the code:

     

        Private Sub btnActualizar_Click(sender As Object, e As EventArgs) Handles btnActualizar.Click

            Dim oCatalog As Catalog = Session.Current.Catalog

            Dim li_q_filas As Integer

     

            Try

               Dim oMITable_LineasTemp As Table = oCatalog.GetTable("LineasTemp")

     

                '------------------------------------------------------------

                ' Actualizo el estilo de un alimentador

                '------------------------------------------------------------

                Dim oMIStyle As New MapInfo.Styles.SimpleLineStyle(New LineWidth(3, MapInfo.Styles.LineWidthUnit.Pixel), 4, Color.Black)

     

                Dim oMIConnection As New MapInfo.Data.MIConnection

                oMIConnection.Open()

     

                Dim oMICommand As MapInfo.Data.MICommand = oMIConnection.CreateCommand

     

                oMICommand.CommandText = "Update LineasTemp Set MI_Style = @style Where Alimentador_MT IN ('5C','L2B')"

                oMICommand.Parameters.Add("@style", oMIStyle)

     

     

                li_q_filas = oMICommand.ExecuteNonQuery

     

                MsgBox(li_q_filas)

     

                '------------------------------------------------------------

                ' Cierro las conexiones

                '------------------------------------------------------------

                oMICommand.Dispose()

                oMIConnection.Close()

     

            Catch ex As Exception

                MsgBox(ex.Message)

            End Try

        End Sub

     

    Thank you!

    Alejandro






  • 7.  RE: Alter tool tip text for existing buttons

    Employee
    Posted 01-07-2020 12:59
    Hi Alejandro,

    Are you trying to update a table that is currently displayed in a Map in MapInfo Pro?
    Or is this a MapXtreme.net question?

    -Bob

    ps. Are you missing parenthesis on  li_q_filas = oMICommand.ExecuteNonQuery()

    ------------------------------
    Bob Fortin
    Software Architect and Distinguished Engineer
    MapInfo Pro Development Team
    ------------------------------



  • 8.  RE: Alter tool tip text for existing buttons

    Posted 01-08-2020 07:26
    Hi Bob

    Yes, I am traing to update a Temp table that is displayed in a map.
    In Mapxtreme 8.1.


    If the table is not display the update runs propertly

    Where is the problem??

    Thank you!





  • 9.  RE: Alter tool tip text for existing buttons

    Employee
    Posted 01-13-2020 23:16
    Edited by Arvind Kumar 01-14-2020 03:15
    Hi Alejandro,

    The column (MI_Style) cannot be updated independently. The Style and Geometry columns must be updated at the same time. (Please refer to MapXtreme_DeveloperGuide.pdf).

    Therefore following code (similar to your scenario) will throw exception:
    ...
    oMICommand.CommandText = "Update " + oMITable_LineasTemp.Alias + " Set MI_Style = @style Where Name IN ('Greg')"
    oMICommand.Parameters.Add("@style", oMIStyle)​
    
    li_q_filas = oMICommand.ExecuteNonQuery
    MsgBox(li_q_filas)


    But, following code will work:
    ...
    Dim ptFeatureGeometry As FeatureGeometry = New Point(MapControl1.Map.GetDisplayCoordSys(), New DPoint(-119, 35))
    oMICommand.CommandText = "Update " + oMITable_LineasTemp.Alias + " Set obj = @geometry, MI_Style = @style Where Name IN ('Greg')"
    oMICommand.Parameters.Add("@geometry", ptFeatureGeometry)
    oMICommand.Parameters.Add("@style", oMIStyle)
    
    li_q_filas = oMICommand.ExecuteNonQuery
    MsgBox(li_q_filas)


    I verified that above scenarios are true for both cases, whether layer is visible or not. Thus you need to update Style and Geometry columns simultaneously.

    But, as you said "If the table is not display the update runs properly", I have not been able to observe the same. Please provide reproducible steps for the same or let us know if the problem with above steps is resolved?


    ------------------------------
    Arvind Kumar
    Knowledge Community Shared Account
    Shelton CT
    ------------------------------