Maptitude GISDK Help |
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
Now you can use the toolbox as before. Your add-in is complete!
©2025 Caliper Corporation | www.caliper.com |