TWIAV - Tips & tricks

TWIAV - Tips & tricks

MapBasic Code Samples


On this page you will find some MapBasic code samples, both the program source and the compiled application. Everything on this page is offered "as is" without warranty of any kind, either expressed or implied, including limitation warranties of merchantability, fitness for a particular purpose, and noninfringement.


Unless otherwise stated MapBasic 9.0 has been used to compile the files - this means that the MBXs offered here will only run with MapInfo Professional 9.0 or higher. If you want to use the tools with another (an older) version of MapInfo Professional, you will have to compile the tool using the relevant version of the Mapbasic compiler.


The MapBasic Code Samples Project


The goal of this project is to provide some examples of how to use certain MapBasic functionality - not to offer full-blown applications. The applications below each focus on one 'trick'. You can study the source, modify it to suit your needs and implement it in your own apps.


The following code samples are available here:





SearchPoint Sample Code


This application demonstrates how to use the SearchPoint() and SearchInfo() function in your MapBasic application.

Click the Bird Button on the SearchPoint Toolbar to see how it works:

  • The cursor becomes a bird when moved over the Map window

  • Click on a French department and a dialog box will tell you where you clicked

Please note: the bird is specifically searching for map objects in the table FR_Départements2006. If you click on map objects in other tables, the bird will not do anything.
Please see the file below for SearchPoint.MB and SearchPoint.MBX.

The table used in the example - FR_Départements2006.TAB - is also included in the zip file:

 SearchPoint.zip

Custom toolbar button and custom cursor

custom toolbar button and custom cursor

In the application a custom toolbar button and a custom cursor is used. This button and cursor are stored in the file Bird.dll (included in the zip file).


The file Bird.dll has been created with Pelles C. In this document you will find a step by step description on how to do this: from creating a new DLL from scratch, store bitmaps in it and call it from your MapBasic application.


Custom Function


In this application a custom function is used. This function - TableIsOpen() - lets you check whether a certain table is open or not.


In this document you will find description of how to create and use a custom function in MapBasic. The function TableIsOpen() is used as an example.


The SearchPoint() and SearchInfo() function







More code samples will follow...;-)



What do you think of these code samples? If you have any , please let me know.