GUI Customization

Project: When a particular session is opened, add a menu with custom functionality to assist or extend the functionality of the host application. The functionality of the custom menu items can be anything supported by or called from the script. Menu modification is just one of several ways the GUI may be customized, see the bottom of this example for suggested extensions.

Algorithm: A menu block is written in the script to redefine the DynaComm session menu, including a custom menu and any default ones that should still be available. Definition of the custom menu also includes each menu item and what they do when selected. For example, the custom menu could add an item to search the screen(s) for a user-entered part number, grab data from screen regions and store to a local file, or retrieve and pass data to an Excel spreadsheet to be graphed immediately. In this example, the custom menu items call script subroutines to provide these functions, but the implementation of the routines themselves is left for future development.

WHEN commands are session specific, so the addition of more WHEN commands could extend this example to cover multiple concurrent sessions. The WHEN commands use an optional window handle parameter to specify which session is being monitored, so it is necessary for the session to be open prior to issuing the WHEN commands for that session. A simple text table is used for data output. See the Data Tables example for further discussion on the use of table.

Relevant Commands and Functions:

MENU — Beginning of Menu block which defines menu
MENU END — Ends Menu block which defines menu
MENU CANCEL — Cancels script-defined menu, restores default menu bar
(MENU) POPUP — Adds a new menu to the menu bar
(MENU) ITEM — Adds a menu item to a popup menu
(MENU) SEPARATOR — Adds a menu item separator to a popup menu
SHOW — Display each script command as it is executed.

See Also:

MENU UPDATE — Updates previously defined menu or menu option
(MENU) INSERT POPUP, (MENU) DELETE POPUP — Inserts/Removes menu from menu bar
(MENU) INSERT ITEM, (MENU) DELETE ITEM — Inserts/Removes a menu item from a popup menu
TITLE — Assign a title to be displayed in DynaComm title bar
SET WINDOWTITLE — Displays title in active child window title bar
SET POINTER — Changes the shape of the mouse pointer
SET SOUND — Controls whether warning bells from host are enabled
SET CURSOR — Changes display of cursor
WINDOW ARRANGE — Tiles open child windows
WINDOW HIDE — Hides window
WINDOW MAXIMIZE — Maximizes specified window
WINDOW MINIMIZE — Minimizes specified window
WINDOW MOVE — Moves and resizes specified window
WINDOW RESTORE — Restores application window to previous state
WINDOW STACK — Stacks open windows in cascade fashion
WINDOW UNHIDE — Displays application window and child windows

A Brief Example

SHOW

MENU
POPUP "&File" SYSTEM 1
POPUP "&Custom"
ITEM "&Query" PERFORM QueryRoutine
ITEM "Screen &Capture" PERFORM ScreenCapture
SEPARATOR
ITEM "&Plot Data" PERFORM PlotData
POPUP "&Help" SYSTEM 8
MENU END
WAIT RESUME
CANCEL

*QueryRoutine
DISPLAY "QueryRoutine executed...menu changes cancelled"
MENU CANCEL
RESUME
RETURN

*ScreenCapture
DISPLAY "ScreenCapture executed...menu changes cancelled"
MENU CANCEL
RESUME
RETURN

*PlotData
DISPLAY "PlotData executed...menu changes cancelled"
MENU CANCEL
RESUME
RETURN

For DCSeries, the menu bar is different for session windows, script windows, memo windows, and the main application window. In this example, we want to modify the session menu bar. Thus, this script should be run when a session window is active. An easy way to do this is to have this script listed as the Startup Script in Session:Properties, General tab.

In this example, the menus are defined as the default menu bar for Session windows, with the omission of the Script menu and with the addition of a Custom menu between Tools and Window. Each of the three routines called by the Custom menu items displays an indication that the routine was performed, cancels the Menu modifications, and causes the script to cancel. Cancelling the script also cancels the menu modifications.

Further Development:

  • When the session using the custom menu is closed, the script can remove the custom menu which is no longer necessary.
  • The title of the session window, and/or the main application can be modified via Script commands.
  • The mouse pointer icon can be changed to an hourglass while waiting for the host to respond, or to indicate the script is processing. The keyboard can also be locked within DynaComm to prevent user input.
  • The cursor appearance can be toggled between available shapes.
  • The session window can be maximized, minimized, stacked, cascaded, dynamically sized, hidden, shown or moved via Script. For example, some host applications may be optimized for a particular session window size. This may also be useful for applications involving multiple coordinated sessions. For example, entering a host monitor application may spawn a secondary session for more detailed output, initially sized smaller and placed below the primary session.