>I would like a tool automatically to be added to the tool manager
>when MapInfo is started. Is there a special directory to which I
>have to copy the tool files? And where do I determine how the menu
>is altered in case the tool is loaded or unloaded?

Here is documentation on that topic:

Registering Your MapBasic Application With the Tool Manager

This document is intended for anyone who distributes a MapBasic
application using an installer program and would like to register
the application with MapInfo Professional's Tool Manager feature.
By registering your application from your installer you can
configure it to run automatically each time MapInfo starts.
Using the Tool Manager dialog, users can load and unload your
application in the same manner as standard MapInfo tool
applications.

The sections below will cover:
 - Registration information
 - Registration functions
 - The concept of a tool's owner
 - The sample installer
 - Creating tool applications

The document assumes you have MapInfo Professional and MapBasic
4.5, or later, and are familiar with the Tool Manager feature (new
in version 4.5).  Also, you should be familiar with calling DLL
functions from a programming language like MapBasic.


Registration Information

Information about registered tools is stored in the system registry
under \\SOFTWARE\MapInfo\MapInfo\Professional\Tools.  Each
registered tool has the following entries:

Title       - name of the tool as it appears in the Tool Manager
              dialog (max 128 chars).
Description - description of the tool as it appears in the Tool
              Manager dialog (max 256 chars).
Location    - fullpath to the MapBasic program file.
Owner       - used at uninstall time (see below) (max 32 chars).
Autoload    - determines whether the tool is loaded when MapInfo
              starts.


Registration Functions

The functions to add and remove tool information from the registry
are in tooltabl.dll, which is located in the same directory as
mapinfow.exe.  The RegisterTool function, used at install time,
takes an argument for each of the fields listed above, in the same
order as listed above.  The UnregisterAllByOwner, used at uninstall
time, takes a single argument; the value of the Owner field used in
the RegisterTool call (see below for more information on how to use
the Owner field).  Here are the declarations of the functions in
several programming languages:

InstallShield
  prototype BOOL tooltabl.RegisterTool(STRING, STRING, STRING,
                                       STRING, BOOL);
  prototype BOOL tooltabl.UnregisterAllByOwner(STRING);

MapBasic
  declare function RegisterTool lib "tooltabl.dll" (
                        byval title as string,
                        byval description as string,
                        byval location as string,
                        byval owner as string,
                        byval autoload as integer) as integer
  declare function UnregisterAllByOwner lib "tooltabl.dll" (
                        byval owner as string) as integer

C/C++
  BOOL RegisterTool(char *szTitle,
                    char *szDesc,
                    char *szLocation,
                    char *szOwner,
                    BOOL bAutoload);
  BOOL UnregisterAllByOwner(char *szOwner);


A Tool's Owner

The Owner field is used to uninstall a tool and should be set to
a value unique to your application.  For example, MapInfo's
installer uses the value "MI_TOOLS" when registering its tools.
MapInfo's uninstaller uses the same value in the call to
UnregisterAllByOwner() to remove all the entries whose Owner
value is "MI_TOOLS".


The following is the basic algorithm for a sample installer:

 - Find the directory in which MapInfo is installed
 - Verify that mapinfow.exe exists
 - Verify that mapinfow.exe version is at least 4.5
 - Prompt user to pick a target directory for the MapBasic
     application file(s)
 - Extract the application files to the target directory
 - Verify that tooltabl.dll exists in the MapInfo directory
 - Load tooltabl.dll
 - Call RegisterTool
 - Unload tooltabl.dll

Unregistering your application in an InstallShield uninstaller
requires the call to UnregisterAllByOwner be made from a custom
DLL. For details about writing an uninstall DLL refer to the
InstallShield 3.0 white paper entitled "Calling a Custom DLL
Function from unInstallShield" (available at
http://support.installshield.com).


Creating Tool Applications

The source code for toolapp.mbx (the MapBasic program installed
by the sample script) is included with the sample code
distributed with MapBasic 4.5, in the \samples\mapbasic\template
directory.  This program should be used as a guide for creating
tools that behave like those distributed with MapInfo Professional.
The following aspects of the toolapp.mbx are worth noting:

Minimal Startup Code
Your application may be autoloaded along with other applications,
so keep your start up operations to a minimum and do not display
dialogs or other user interface objects that will halt the
autoloading.  User interface objects should be displayed only as
a result of the user taking some action after your application is
loaded (e.g. selecting a menuitem).

Modifying the Tools menu
As of MapInfo 4.5 the Tools menu is a member of the default menu.
Previously, tools had to explicitly add and remove Tools from the
menu bar.  This is no longer necessary, and in fact should not be
done.  If you want your application's menu to appear under the
Tools menu, then use the function set_tools_menu, defined in
autolib.mb (also included with the MapBasic sample code).  Using
this function will ensure your application is added to the Tools
menu in the correct manner.  There is no action required to remove
your application from the Tools menu; MapInfo will do this
automatically when your application terminates.

Standard Menu Format
Define standard menuitems "Exit" and "About", using the standard
shortcut keys.  Separate these items from your application's items
using the separator bar.  Provide shortcut keys for your
application's items.


Additional Notes

Before the Tool Manager feature existed in MapInfo Professional,
MapBasic tool applications often included an 'Auto-load' button
in their About dialog box.  Pushing the button resulted in a
'Run Application' statement being added to startup.wor and the
tool being loaded when MapInfo started.  This method still works
and will not conflict with the Tool Manager's autoloading feature.
Just make sure you don't support both methods, or your application
may be autoloaded twice.

MapInfo Professional's uninstaller removes all registry entries
related to MapInfo, including the Tool Manager entries.

----------------------------------------------------------------------
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

Reply via email to