home *** CD-ROM | disk | FTP | other *** search
/ Mega CD-ROM 1 / megacd_rom_1.zip / megacd_rom_1 / DESQVIEW / DVGLU101.ZIP / UISIGNAL.C < prev    next >
C/C++ Source or Header  |  1988-08-11  |  2KB  |  58 lines

  1. /*======================================================*/
  2. /*  UISIGNAL.C                                          */
  3. /*                                                      */
  4. /* (c) Copyright 1988 Ralf Brown.  All Rights Reserved. */
  5. /*======================================================*/
  6.  
  7. #include <stdio.h>
  8. #include "tvapi.h"
  9. #include "tvstream.h"
  10. #include "tvui.h"
  11.  
  12. /*======================================================*/
  13.  
  14. static void (*signal_handlers[TV_MENU_END-TV_HMOVE+1])(NOTIFY_MSG *) ;
  15.  
  16. /*======================================================*/
  17. /*======================================================*/
  18.  
  19. static void far UIsignal_handler(void)
  20. {
  21.    NOTIFY_MSG msg ;
  22.    PARMLIST2 p ;
  23.  
  24.    while (TVmbx_size(NIL) > 0)
  25.       {
  26.       (void) TVreadmail(NIL,(char *)&msg,sizeof(msg)) ;
  27.       msg.event -= MS_NOTIFY ;
  28.       if (msg.event >= TV_HMOVE && msg.event <= TV_MENU_END && signal_handlers[msg.event] != NULL)
  29.          (*signal_handlers[msg.event])(&msg) ;
  30.       }
  31. }
  32.  
  33. /*======================================================*/
  34. /* UIsignal   set up handlers for specified notify msgs */
  35. /*   Ralf Brown 8/1/88                                  */
  36. /*======================================================*/
  37.  
  38. void (* pascal UIsignal(int signal,OBJECT window,void (*handler)(NOTIFY_MSG *),int stacksize))(NOTIFY_MSG *)
  39. {
  40.    void (*old_handler)(NOTIFY_MSG *) ;
  41.  
  42.    old_handler = signal_handlers[signal] ;
  43.    signal_handlers[signal] = handler ;
  44.    if (handler != NULL)
  45.       {
  46.       /* we may not have installed the handler on this window yet */
  47.       if (TVwin_async(window,UIsignal_handler,stacksize) == EOF)
  48.          return SIGNAL_ERROR ;
  49.       TVwin_notify(window,signal) ;
  50.       TVwin_allow(window,signal) ;
  51.       }
  52.    else
  53.       TVwin_cancel(window,signal,TRUE) ;  /* remove handler if last signal cancelled */
  54.    return old_handler ;
  55. }
  56.  
  57. /* End of UISIGNAL.C */
  58.