Maptitude GISDK Help

Lesson 4: Calling the Toolbox from the Menus

Now it is time to stop calling the toolbox from a test macro, and instead add a menu to the Maptitude menu bar to call it. You will also see how your source code can be kept in separate files, but be compiled into a single program.

 

Your code for adding the new menu will be kept in lessson4.rsc in the gisdk\samples folder. An additional file, lessson4.lst, contains a list of the source code files to be compiled. It includes a reference to the lessson3.rsc file, which we will use unchanged, and also a reference to your new code, lessson4.rsc, which is shown below:

 

// This code is in lesson4.rsc.

// Add a "Lesson" menu with a "Find and Zoom" item to the main menu  

Macro "lesson4"

 

    // This macro adds the "Lesson" menu before the "window" menu

    // First, make sure the "Lesson" menu is not already there.

    // This error handler prevents an error message if the menu isn't there.

    on NotFound goto next

 

    // Now remove the menu,...

    RemoveMenuItem("GISDK Lesson Menu")

 

    // Reset the error handling,...

next: on NotFound default

 

    // And add the menu

    AddMenuItem("GISDK Lesson Menu", "Before", "Window")

endMacro

 

Menu "Lesson Menu System"

 

    // This is the top-level title to be added to the main menu system

    MenuItem "GISDK Lesson Menu" text: "Lesson" key: alt_l

        menu "Lesson Dropdown Menu"

endMenu

 

Menu "Lesson Dropdown Menu"

 

    // This is the body of the drop-down menu to be added

    MenuItem "Find and Zoom" text: "Find and Zoom" key: alt_Z

        do

 

            // Open the toolbox

            RunDbox("find and zoom toolbox")

        endItem

endMenu

 

To Compile and Run Lesson 4

  1. From your text editor, open and examine the contents of the lesson4.rsc and lesson4.lst files in the gisdk\samples folder.
  2. From Maptitude, click dkimage\ebx_792478206.gif in the GISDK Toolbox to display the Compile File dialog box.
  3. Choose the file named lesson4.lst in the gisdk\samples folder, and click Open. GISDK compiles both the files listed into a single compiled program.
  4. Click on the Lessons map to make it the active window.
  5. Click dkimage\ebx_-816932350.gif in the GISDK Toolbox to display the Test an Add-In dialog box.
  6. Type "lesson4" in the Name text box.
  7. Click OK. The Lesson menu is added to the menu bar, and it has one command, Find and Zoom.
  8. Choose Lesson-Find and Zoom. The add-in displays the toolbox created in Lesson 2.

Now you can use the toolbox as before. Your add-in is complete!

 

Go to Lesson 5: Installing the Add-in.

 

 

©2025 Caliper Corporation www.caliper.com