【正文】
CAD client area MinimizeWindow() Minimizes (iconizes) the specified window 12 RestoreWindow() Restores a window to its original size ArrangeIcons() Arranges all minimized windows Here is a short example: // Set the frame (the program window) to fill the entire screen SetWindowPosition(Frame|, 0, 0) SetWindowSize(Frame|, 100, 100) // Now, get the names of all the windows win_info = GetWindows() win_names = win_info[1] win_types = win_info[2] //Loop over windows, minimizing all editors and layouts for i = 1 to if win_types[i] Map then MinimizeWindow(win_names[i]) end // Finally, tile all the maps on the screen TileWindows() Attaching Menus and Toolbars Every window can have its own menu and toolbar. When you attach a menu or toolbar to a window, GISDK automatically displays the correct menu and toolbar whenever the window is activated. When you build a custom application, the opening menu and toolbar (the ones that are attached to the frame window) are designated using SetDefaults(). You can also use SetDefaults() to set default menus and toolbars independently for each window type. You can assign a single menu to more than one window, or assign menus and toolbars to windows independently. TransCAD, for example, uses a single menu for all windows, but different toolbars for each type of window. Window Macros GISDK lets you attach four types of macros to windows, so that you can perform certain types of processing automatically when the user takes certain kinds of actions. 13 Activate macros run automatically when a user clicks in a window on the screen to activate it, or when a window bees active because the previously active window is closed. When the last map, editor, or layout is closed, the frame is activated and the activate macro for the frame runs. Activate macros are typically used to enable and disable menu items and tools, so that only the appropriate mands are available. When you click from window to window in TransCAD, the following things occur: ?? the platform automatically displays the correct menu system and toolbar ?? the activate macro for the window checks the current state of the window, and enables and disables menu options and tools as appropriate Close macros run when the user chooses Close from the system menu, or clicks the close box in the upperleft hand corner of the window. Close macros normally ask the user to confirm that the window should be closed and perform any necessary bookkeeping. If the close macro returns null, the window closes automatically. If the close macro returns any other value, the window does not close. Scalechange macros are attached only to map windows, and run automatically when the scale of the map changes. For example, if the user zooms in using the zoom tool, or changes the map window size (which affects the scale as well), the scalechange macro runs automatically. Highlight macros are attached only to editors, and run automatically when the highlighted cells in the editor change. This happens each time the user clicks in a cell, clicks on a column heading, or drags a highlight across a set of rows and columns. You can use SetDefaults() to assign default window macros to each type of window. For more information, see... Window Macros An Example Window Macros An Example Here is a sample that uses several types of window macros. This macro creates two map windows and one editor window, tiled on the screen. When you activate either map, the activate macros set the current layer to be the first area layer in the map. When either map window is closed, the close macros display a message. When you click in an editor, a message displays the number of highlighted cells. // This macro creates three windows Macro set things up map1 = OpenMap(tutorial\\, // open the first map file { 14 {Activate Macro, activate map}, // runs when window is activated {Close Macro, close map 1} // runs when window is closed }) map2 = OpenMap(tutorial\\, // open a second map file { {Activate Macro, activate map}, // and the same activate macro {Close Macro, close map 2} // and a different close macro }) ed1 = OpenEditor(tutorial\\, null) // open a dataview file SetEditorOption(ed1, Highlight Macro, check editor highlight) // set a highlight macro TileWindows() // arrange windows sidebyside endMacro // Here are the other macros: // This macro runs when ANY map is activated Macro activate map lyr_info = GetMapLayers( , Area) // Get info on area layers in current map first_layer = lyr_info[1][1] // Read the name of the first area layer SetLayer(first_layer) // Make that layer current endMacro // This macro runs when the first map is closed Macro close map 1 ShowMessage(Your first map is about to close!) // Display a message or two... ShowMessage(The current layer is + GetLayer()) Return(null) // The map window closes... endMacro // This macro runs when the second map is closed Macro close map 2 ShowMessage(Your second map is about to close!) // A different message... ShowMessage(The current layer is + GetLayer()) Return(null) // The map window closes... endMacro // This macro runs whenever the highlighted cells in the editor change Macro check editor highlight tmp = GetEditorHighlight() // read the size of the highlighted area if tmp = null then ShowMessage(You didn39。t highlight anything!) else if tmp[1] = null then ShowMessage(You highlighted a row!) else if tmp[2] = null then ShowMessage(You highlighted a column!) 15 else do ncells = String(tmp[1].