home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / Event / c / MRelWindow < prev   
Encoding:
Text File  |  1992-03-31  |  2.0 KB  |  59 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Event.MRelWindow.c
  12.     Author:  Copyright © 1992 Jason Williams
  13.     Version: 1.00 (16 Mar 1992)
  14.     Purpose: Extension to Event.c to allow routing of specific message types
  15.              to different windows' message handlers.
  16. */
  17.  
  18. #include "EMsgDefs.h"
  19.  
  20. extern linklist_header eventmsg__claimanchor;
  21.  
  22.  
  23. extern int EventMsg_ReleaseWindow(window_handle window)
  24. {
  25.   eventmsg_claimrecord *ptr, *nextmess;
  26.   eventmsg_windowrecord *wptr, *next;
  27.   int result = 0;
  28.  
  29.   ptr = (eventmsg_claimrecord *) eventmsg__claimanchor.next;
  30.  
  31.   while (ptr != NULL)                           /* Search all message claims */
  32.   {
  33.     wptr = (eventmsg_windowrecord *) ptr->windowlist.next;
  34.     while (wptr != NULL)                        /* Search all window claims  */
  35.     {
  36.       next = (eventmsg_windowrecord *) wptr->header.next;
  37.       if (wptr->window == window)          /* found a claim for this window  */
  38.       {
  39.         LinkList_Unlink(&(ptr->windowlist), &(wptr->header));
  40.         free(wptr);
  41.         result += 1;                       /* Count of window claims removed */
  42.       }
  43.       wptr = next;
  44.     }
  45.  
  46.     nextmess = (eventmsg_claimrecord *) ptr->header.next;
  47.     if (ptr->windowlist.next == NULL)                 /* m-list is now empty */
  48.     {
  49.       LinkList_Unlink(&eventmsg__claimanchor, &(ptr->header));
  50.                                                       /* remove message type */
  51.       free(ptr);                                      /* free memory up      */
  52.     }
  53.  
  54.     ptr = nextmess;
  55.   }
  56.  
  57.   return(result);
  58. }
  59.