MapInfo Pro

Expand all | Collapse all

Run Menu Command M_TOOLS_MAPBASIC

  • 1.  Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-07-2020 10:00
    ​Hi,
    The command "Run Menu Command M_TOOLS_MAPBASIC", worked in MapInfo v15 and previous versions.  But when I tested in MapInfo v17, it does not work.

    Can someone please help me on this.

    I would also like to understand the process when after making call to M_TOOLS_MAPBASIC.

    Thank you,
    Mariana

    ------------------------------
    Mariana S.
    GOC INDUSTRY CANADA
    Stoney Creek ON
    ------------------------------


  • 2.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-07-2020 13:31
    Edited by Bob Fortin 04-07-2020 13:32
    Hi Mariana,

    You are correct. That button was not kept when we went to 64 bit.
    Is this for a tool you have the source code to? We could show you how to add a ribbon tool button to do something similar.

    Also, we will look to put it back in a future release.

    There is a help topic for it in the MapBasic reference guide - search for M_TOOLS_MAPBASIC

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



  • 3.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-07-2020 14:16

    Hi Bob,

    Thank you so much for getting back to me.  Yes, it is coded in MapBasic. My retired boss wrote the code.  I need help on making the code to run again.

     

    I read about Run Menu Command M_TOOLS_MAPBASIC from MapBasic Reference guide.  Thank you, now I understand how it works.

     

    It would be nice if you put it back in the future release.

     

    But now I need your help to fix my code.  Could you please tell me how to add a ribbon tool button which will do the same function.

     

    Thanks,

    Mariana

     






  • 4.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-07-2020 15:50
    Edited by Bob Fortin 04-07-2020 15:53
    Hi Mariana,

    I learned a little more this afternoon. If your mbx has a toolhandler procedure it kind of works (I tried 2019.1).
    The tool button is added to the Legacy Tab, and if you click on it the tool handler is called.

    As you found the Run Menu Command M_TOOLS_MAPBASIC does not work to activate the tool, but you still click on it with the mouse.

    Here is a minimal mb program that adds a ribbon button onto the "MAP" tab and calls a custom handler.
    I think it requires at least version 17.01.

    If you have an existing ToolHandler you could just rename it to MyToolHandler.

    Include "mapbasic.def" 
    Include "icons.def" 
    Include "RibbonControls.def"
    
    Declare Sub MyToolHandler
    Declare Sub EndHandler
    
    Sub MyToolHandler 
    	Note "x:" + Round(CommandInfo(CMD_INFO_X), 0.1) + Chr$(10) +
    		" y:" + Round(CommandInfo(CMD_INFO_Y), 0.1) 
    End Sub
    
    Sub EndHandler
    ' do any cleanup here
    End Sub
    
    Alter ButtonPad TAB_MAP_SELECTION_GRP Tab TAB_MAP
    	Add ToolButton Calling MyToolHandler ID 1234 Large 
    	HelpMsg "My Button Tooltip\nMy Button" Cursor MI_CURSOR_LRG_CROSSHAIR
    
    
    

    Let me know if it you have any trouble with it.

    -Bob

    ps. I am curious if you would prefer to use Python instead of MapBasic



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



  • 5.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-08-2020 08:31

    Hi Bob,

    That's a great news.  I have the Toolhandler procedure in the code.  The  call to Run Menu Command M_TOOLS_MAPBASICS in MapInfo v17, does not have any response, not even error message, it behaves as if its frozen.   But the same code works well in MapInfo v15.

     

    Here is my observation between expected behaviour and behaviour in MapInfo v17.

     

     

    We have a menu item called "Point", once clicked on it, it is supposed to do the followings:

    1.            Change mouse to   shape and wait for the user to click on the Map window.

    2.            Once the user clicks on the map window, Toolhandler sub gets called

    3.            Creates points and display it on the map

     

    In MapInfo v17, here is what happened after I clicked on the menu item "Point"

    1.            The mouse did not change

    2.            I clicked on the map window, Toolhandler Sub did not get called (I did a print statement to test this)

    3.            Did not create point object on the map

    4.            No error message returned at all

     

     

    Could you please give me a simple mapbasic code to test that Run Menu Command M_TOOLS_MAPBASICS works?  I have both MapInfo v15 and v17 installed on my computer.

     

    Thank you,

    Mariana

     

     






  • 6.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-08-2020 10:45
    Hi Mariana,

    What version exactly do you have? 17.0 or 17.1 or later?

    First, can you look on the ribbon and see if there is a "LEGACY" tab with the tool button on it when your mbx is loaded? If so try it out.

    Second, where is the menu item that you are clicking on called "Point"?
    Can you send me your code so I can try to fix it for you?  Use the "reply privately" to do this.

    -Bob


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



  • 7.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-15-2020 14:41

    Hi Bob,

     

    1)      I could not find "RibbonControls.def" file. 

    But I found "RibbonCustomizationMB.def", is this the file you wanted me to include?

     

    2)      I have attached a sample file I created. Where it works in MapInfo 15 and not in MapInfo 17.

     

    Thanks,

    Mariana

     

     

     






  • 8.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-18-2020 08:36
    Hi Mariana,

    I cannot see the attachment. I think it needs to be in a .zip file.

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



  • 9.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-20-2020 07:46

    Hi Bob,

     

    Please see below.

     

    Include "C:\Program Files (x86)\MapInfo\MapBasic\mapbasic.def"

    Include "C:\Program Files (x86)\MapInfo\MapBasic\menu.def"

    Include "C:\Program Files (x86)\MapInfo\MapBasic\icons.def"

     

    Declare Sub Main

    Declare Sub Draw_point

    Declare Sub draw_line

    Declare Sub ToolHandler

     

    Global toolhandler_flag as SmallInt

    Global xstart, ystart, xend, yend as Float

     

    Define T_DRAW_ONE_POINT     4

    Define T_DRAW_LINE_PT1      5

    Define T_DRAW_LINE_PT2      6

       

     

     

    Sub Main

                                   ' Create Tools menu

        Create Menu "&SV_Tools" as

           "&Point"      helpmsg "Draw a symbol at a given location"

                         Calling Draw_point,

           "&Line"          helpmsg "Draw a line between two given points"

                         Calling Draw_line

     

    Alter Menu Bar Add "&SV_Tools"

     

     

     

    End Sub

     

     

     

    Sub Draw_point

     

        toolhandler_flag = T_DRAW_ONE_POINT

     

        Run Menu Command M_TOOLS_MAPBASIC

     

     

    End Sub

     

    Sub draw_line

     

        toolhandler_flag = T_DRAW_LINE_PT1

     

        Run Menu Command M_TOOLS_MAPBASIC

     

     

    End Sub

     

     

    Sub ToolHandler

     

        Do Case toolhandler_flag

                                  

           Case  T_DRAW_ONE_POINT

              xstart = CommandInfo (CMD_INFO_X)

              ystart = CommandInfo (CMD_INFO_Y)

     

    Print "Point, xstart = " +xstart

    Print "Point, ystart = " +ystart

     

           Case T_DRAW_LINE_PT1

              xstart = CommandInfo (CMD_INFO_X)

              ystart = CommandInfo (CMD_INFO_Y)

     

    Print "--------------------------------------------------------"

    Print "Line, xstart1 = " +xstart

    Print "Line, ystart1 = " +ystart

     

              toolhandler_flag = T_DRAW_LINE_PT2

             

           Case T_DRAW_LINE_PT2

              xend = CommandInfo (CMD_INFO_X)

              yend = CommandInfo (CMD_INFO_Y)

     

    Print "Line, xstart2 = " +xstart

    Print "Line, ystart2 = " +ystart

     

        End Case

     

    End Sub

     

     

     

     

     

     






  • 10.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-20-2020 12:01
    Hi Mariana,

    Here is a version of your code that should work in version 17.01 or later.
    It creates two 'Tool' buttons on the legacy tab instead of the menu.
    For the line, I used a drawmode of cutom line, so you have to click and drag to draw a line. (Not sure if this is what you need but it seemed like a good idea.)

    Try it out and let me know if you need any more help.

    Include "mapbasic.def"
    Include "menu.def"
    Include "icons.def"
     
    Declare Sub Main 
    Declare Sub Draw_point
    Declare Sub draw_line 
    Declare Sub EndHandler
    
     
    Global toolhandler_flag as SmallInt
    Global xstart, ystart, xend, yend as Float
     
    Define T_DRAW_ONE_POINT	4
    Define T_DRAW_LINE	5
    		
    Sub Main
    	' add two buttons to legacy tab
    	Alter ButtonPad "SV_Tools"
    		Add ToolButton Calling Draw_point ID T_DRAW_ONE_POINT Large ICON MI_ICON_SYMBOL
    			HelpMsg "Draw a symbol at a given location\nPoint" Cursor MI_CURSOR_LRG_CROSSHAIR
    		Add ToolButton Calling Draw_line ID T_DRAW_LINE Large ICON MI_ICON_LINE DrawMode DM_CUSTOM_LINE
    			HelpMsg "Draw a line between two given points\nLine" Cursor MI_CURSOR_LRG_CROSSHAIR
    End Sub 
     
    Sub Draw_point
    			xstart = CommandInfo (CMD_INFO_X)
    			ystart = CommandInfo (CMD_INFO_Y)
    			Print "Point, xstart = " + xstart
    			Print "Point, ystart = " + ystart
    End Sub
     
    Sub draw_line 
    			xstart = CommandInfo (CMD_INFO_X)
    			ystart = CommandInfo (CMD_INFO_Y)
    			Print "--------------------------------------------------------"
    			Print "Line, xstart1 = " + xstart
    			Print "Line, ystart1 = " + ystart
    			xend = CommandInfo (CMD_INFO_X2)
    			yend = CommandInfo (CMD_INFO_Y2)
    			Print "Line, xstart2 = " + xstart
    			Print "Line, ystart2 = " + ystart
    End Sub
     
    Sub EndHandler
    ' do any cleanup here
    End Sub
    ​

    -Bob

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



  • 11.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-20-2020 14:31

    HI Bob,

     

    First of all, having a menu is a user's requirement.  The users have been using this program for years and I they won't like it any other way.

     

    Second of all, I don't think tool button will work in my case.  The reason is the menu item has a series of steps.  Click on the map and read location is just one of the many steps. 

     

    For example,  the menu item "Point", gives the user the option to select from a radio group whether the user would like to click on the map to create point, or enter coordinate to create point.  How can this be done using Tools button?

     

    If you can make the sample program I gave you in my previous e-mail.    That will solve the problem for so many menu items in my program. 

     

    If not, keeping the menu item and somehow if you can make automatic call to toolbutton when the user select "click on the map to create point".  This will work also.

     

    Thanks,

    Mariana

     

     






  • 12.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-22-2020 18:43
    Hi Mariana,

    Without knowing your whole program I made some choices. I will re-work your example to use menu items.
    I will get back in a few days.

    -Bob

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



  • 13.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-23-2020 07:12

    Thank you so much.  I can't wait to get a solution to this problem.

     

    Thanks,

    Mariana

     






  • 14.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-24-2020 08:52
    Just an update. We have fixed the tool handler. It will be available in the next release.

    (I will still get you a solution for now)

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



  • 15.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-24-2020 09:13

    Hi Bob,

    I am forwarding this message to my manager. 

     

    Thanks,

    Mariana

     






  • 16.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-24-2020 09:22

    Sounds good Bob.  Thank you for trying to find a solution.

     

    Mariana

     






  • 17.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-24-2020 09:46

    HI Bob,

    When you said it will be available in the next release, what does it mean?

     

    It will be available in patch in December, 2020?

    Or in MapInfo v18?

     

    What does it exactly mean?

     

    Thanks,

    Mariana

     

     






  • 18.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-24-2020 09:58

    HI Bob,

    When you said it will be available in the next release, what does it mean?

     

    It will be available in patch in December, 2020?  Can the patch be applied to MapInfo v17 ore v18?

     

    What does it exactly mean?  Please clarify.

     

    Thanks,

    Mariana

     

     






  • 19.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-24-2020 10:55
    Hi Mariana,

    This solution is very close to what you sent me.

    Instead of using the MapBasic Tool handler button and handler, it uses a custom tool button and custom handler.
    Instead of run menu command  Run Menu Command M_TOOLS_MAPBASIC  Run Menu Command M_TOOLS_MAPBASIC
    in uses  Run Menu Command ID 1234
    which is the id given to the custom tool button

    Let me know if it solves your problem.

    -Bob

    Include "mapbasic.def"
    Include "menu.def"
    Include "icons.def"
     
    Declare Sub Main 
    Declare Sub Draw_point
    Declare Sub draw_line 
    Declare Sub MyToolHandler
    Declare Sub EndHandler
     
    Global toolhandler_flag as SmallInt
    Global xstart, ystart, xend, yend as Float
     
    Define T_DRAW_ONE_POINT	4
    Define T_DRAW_LINE_PT1	5
    Define T_DRAW_LINE_PT2	6
    		
    Sub Main
    	 ' Create Tools menu 
    		Create Menu "&SV_Tools" as
    			 "&Point"      helpmsg "Draw a symbol at a given location"
    										 Calling Draw_point,
    			 "&Line"          helpmsg "Draw a line between two given points"
    										 Calling Draw_line
     
    	Alter Menu Bar Add "&SV_Tools"
     
    
    	Alter ButtonPad "SV_Tools"
    	Add ToolButton Calling MyToolHandler ID 1234 Large HelpMsg "SV Tool Tooltip\nSV Tool" Cursor MI_CURSOR_LRG_CROSSHAIR
    End Sub 
     
    Sub Draw_point
    		toolhandler_flag = T_DRAW_ONE_POINT
    		Run Menu Command ID 1234 
    End Sub
     
    Sub draw_line 
    		toolhandler_flag = T_DRAW_LINE_PT1
    		Run Menu Command ID 1234 
    End Sub
     
     
    Sub MyToolHandler
    	Do Case toolhandler_flag
    			
    		Case	T_DRAW_ONE_POINT
    			xstart = CommandInfo (CMD_INFO_X)
    			ystart = CommandInfo (CMD_INFO_Y)
    			Print "Point, xstart = " + xstart
    			Print "Point, ystart = " + ystart
     
    		Case	T_DRAW_LINE_PT1
    			xstart = CommandInfo (CMD_INFO_X)
    			ystart = CommandInfo (CMD_INFO_Y)
    			Print "--------------------------------------------------------"
    			Print "Line, xstart1 = " + xstart
    			Print "Line, ystart1 = " + ystart
    			toolhandler_flag = T_DRAW_LINE_PT2
    					
    		Case	T_DRAW_LINE_PT2
    			xend = CommandInfo (CMD_INFO_X)
    			yend = CommandInfo (CMD_INFO_Y)
    			Print "Line, xstart2 = " + xstart
    			Print "Line, ystart2 = " + ystart
    		End Case
    End Sub
    
    Sub EndHandler
    ' do any cleanup here
    End Sub
    ​


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



  • 20.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Employee
    Posted 04-24-2020 10:59
    The fix will be available in version 2019.2 currently targeted for the summer.
    Hopefully the solution I just posted will be sufficient til then.

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



  • 21.  RE: Run Menu Command M_TOOLS_MAPBASIC

    Posted 04-24-2020 12:05

    Hi Bob,

    Thank you so much for the information. 

     

    Mariana