MapInfo Pro Developers User Group

Welcome to the MapInfo Pro Developers community!  We are a group dedicated to the discussion and understanding of MapBasic and .Net MapInfoPro AddIn development. Bring your questions and ideas here. This group includes several members of the Pro development team from around the world.

Please feel free to start a discussion in the discussion tab or join in a conversation.

Product Information  Ideas Portal  MapInfo Community Downloads

Discussions

Members

Resources

Events

 View Only

I write Mapbasic programs for users in my company. They are asking me if I can write a program that will run queries based on objects they select in a map.

  • 1.  I write Mapbasic programs for users in my company. They are asking me if I can write a program that will run queries based on objects they select in a map.

    Posted 02-14-2018 16:47

    Ideally they would select the items then click a mapbasic button in the ribbon and a dialog will open with other selectable options then click OK to run the ODBC query. I can do every thing except knowing what they clicked in the map. Can you point me in the right direction on how I might achieve that? So maybe there would be a listbox of the selection(s)? I don't know



  • 2.  RE: I write Mapbasic programs for users in my company. They are asking me if I can write a program that will run queries based on objects they select in a map.

    Employee
    Posted 02-15-2018 05:46

    I see two ways forward

    Get coordinate

    If you want to grab the coordinates where the user clicked in the map, I would recommend that you create a ToolButton with a Point Draw Mode.

    This will work like the Info tool - kind of - but you need to create the intelligence behind the procedure.

    The handler of the ToolButton is called when the user uses the tool and click in the map.

    Within the handler/subprocedure you can now get the coordiantes where the tool was used using the CommandInfo(CMD_INFO_X) and CommandInfo(CMD_INFO_Y) function.

    Get Selection

    Another way forward is to use the feature your user has selected, if any.

    You can basically asume that the user has selected a single record before he clicks your button on the ribbon.

    When the button is clicked, you can check whether a selection exists. If it does proceed, if not tell the user to select the record they want to "work" on. You can also use the SelChangedHandler to enable/disable your button based on the current number of selected records.

    If you proceed you can can refer to the query Selection as the current selected record(s) to process.