Sie sind auf Seite 1von 2

Lesson 4: Calling the Toolbox from the Menus Página 1 de 2

TransCAD 7 Help
Home / Welcome to 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 TransCAD 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 "Get Best Route" 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 "Get Best Route" text: "Get Best Route" key: alt_Z
do

// Open the toolbox


RunMacro("lesson3")
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

mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017
Lesson 4: Calling the Toolbox from the Menus Página 2 de 2

GISDK\SAMPLES folder.

2. From TransCAD, click 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 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, Get Best Route.

8. Choose Lesson-Get Best Route. 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.

©2015 Caliper Corporation www.caliper.com

mk:@MSITStore:C:\Program%20Files%20(x86)\TransCAD%207.0\transcaddk.chm::/dk... 05-05-2017

Das könnte Ihnen auch gefallen