Generic Subroutines

In addition to code reuse at the application object level, significant productivity gains can be achieved by the reuse of application code at the subroutine level, to carry out common operating system and Presentation Manager functions.

For example, initialization functions are required to perform tasks related to initializing the Presentation Manager environment and any data areas to be used by utility routines. Functions required to be performed include:

  • Registration of the application to Presentation Manager
  • Creation of a message queue
  • Creation of an entry in the Workplace Shell Window List.

    These functions may be combined into one or more standard initialization routines, which may be invoked upon entry to an application or thread. Examples of the necessary code are given in Figure "Sample Application Main Routine (Part 1) - Registration", Figure "Sample Application Main Routine (Part 2) - Window Creation" and Figure "WinAddSwitchEntry() Function".

    Termination functions required by Presentation Manager applications could also be standardized; these functions include:

  • Removing the application from the Workplace Shell Window List
  • Destroying the application's main window
  • Destroying the primary thread's message queue
  • Deregistration of the application from the Presentation Manager environment.

    These operations are performed by Presentation Manager upon termination of the application if the application does not perform them explicitly. However, it is recommended that the application carries out these actions, since they may then be achieved in a controlled manner. Examples of the necessary code are given in Figure "Sample Application Main Routine (Part 2) - Window Creation".

    Other functions may often be required during the execution of an application, such as:

  • Obtaining the window handle of the application's main client window. An example of this procedure is given in Identifying the Destination Window.

  • Passing a message from a subclass window procedure to the original window procedure for that window class. An example is given in Figure "Subclass Window Procedure".

    These functions may also be combined into standard subroutines and placed in a library, thereby avoiding the need for application developers to repetitively code such functions.

    A final function often used in the stepwise development of object-oriented Presentation Manager applications is a small routine to display a message box with the message "Action Not Yet Implemented", invoked when the user selects a menu bar or pulldown entry for which a method has not yet been coded. This function is typically invoked as the default case for the WM_COMMAND message class. In this way, methods within a window procedure may be implemented in a stepwise manner, and testing of existing methods may occur while new ones are being added. Selecting an action for which no method has yet been implemented will always result in the same message box being displayed.


    [Back: Dialog Boxes]
    [Next: Granularity]