home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / genhdrs / cmdhdrs / cmdhdrs.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  1.7 KB  |  60 lines

  1. //*********************************************************
  2. // Reusable Handlers - Simple Command Handler
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //*********************************************************
  8. #include <iapp.hpp>
  9. #include <icnrctl.hpp>
  10. #include <iframe.hpp>
  11. #include <icconst.h>
  12. #include "cmdhdr1.hpp"
  13. #include "cmdhdr2.hpp"
  14. #include "popuphdr.hpp"
  15.  
  16. void main ( )
  17. {
  18.   // Create a frame window with a container client window.
  19.   IFrameWindow
  20.     frame( "Command Handlers" );
  21.   IContainerControl
  22.     client( IC_FRAME_CLIENT_ID, &frame, &frame );
  23.   frame
  24.    .setClient( &client );
  25.  
  26.   // Set up the container.
  27.   client
  28.    .setTitle( "Press mouse button 2 to display a pop-up menu." )
  29.    .showTitle()
  30.    .showTitleSeparator();
  31.  
  32.   // Add a container menu handler to display a pop-up menu.
  33.   PopupMenuHandler
  34.     popupHandler;
  35.   popupHandler
  36.    .handleEventsFor( &client );
  37.  
  38.   // Attach the command handlers.  These will process the
  39.   // commands invoked when a user selects a choice from the
  40.   // container's pop-up menu.  Note that we attach command
  41.   // handlers to the container client window only after we
  42.   // attach its container menu handler.  This ensures that the
  43.   // container menu handler does not cause command handlers to
  44.   // be bypassed.  You can attach either command handler to
  45.   // the frame or client window.
  46.   OneBeepCmdHandler
  47.     oneBeepHandler;
  48.   oneBeepHandler
  49.    .handleEventsFor( &client );
  50.   TwoBeepCmdHandler
  51.     twoBeepHandler;
  52.   twoBeepHandler
  53.    .handleEventsFor( &frame );
  54.  
  55.   frame
  56.    .setFocus()
  57.    .show();
  58.   IApplication::current().run();
  59. }
  60.