home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / languages / c / oslib / Examples / p3-231 < prev    next >
Text File  |  1994-03-24  |  1KB  |  49 lines

  1. #include "os.h"
  2. #include "wimp.h"
  3.  
  4. #define EXIT 6 /*position in Task Manager menu of Exit entry*/
  5.  
  6. extern wimp_block *Block;
  7. extern wimp_t Quit_Sender;
  8. extern wimp_message Pre_Quit_Block, Quit_Block;
  9. extern int Event, Pre_Quit_Ref, Quit_Ref;
  10. extern Quit (void);
  11.  
  12. void ex1 (void)
  13.  
  14. {  wimp_get_caret_position (&Block->caret);
  15.    Block->key.c = wimp_KEY_SHIFT | wimp_KEY_CONTROL | wimp_KEY_F12;
  16.    wimp_send_message (wimp_KEY_PRESSED, &Block->message, Quit_Sender);
  17. }
  18.  
  19. void ex2 (void)
  20.  
  21. {  switch (Event)
  22.    {  case wimp_MENU_SELECTION:
  23.          if (Block->selection.items [0] == EXIT)
  24.          {  wimp_send_message (wimp_USER_MESSAGE_RECORDED, &Pre_Quit_Block,
  25.                   wimp_BROADCAST);
  26.             Pre_Quit_Ref = Pre_Quit_Block.my_ref;
  27.          }
  28.       break;
  29.  
  30.       case wimp_USER_MESSAGE_ACKNOWLEDGE:
  31.          if (Block->message.my_ref == Pre_Quit_Ref)
  32.          {  wimp_send_message (wimp_USER_MESSAGE_RECORDED, &Quit_Block,
  33.                   wimp_BROADCAST);
  34.             Quit_Ref = Quit_Block.my_ref;
  35.          }
  36.          else if (Block->message.action == message_QUIT &&
  37.                Block->message.my_ref == Quit_Ref)
  38.             Quit ();
  39.       break;
  40.  
  41.       case wimp_USER_MESSAGE:
  42.       case wimp_USER_MESSAGE_RECORDED:
  43.          if (Block->message.action == message_QUIT &&
  44.                Block->message.my_ref != Quit_Ref)
  45.             Quit ();
  46.       break;
  47.    }
  48. }
  49.