home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d157 / screenzap.lha / ScreenZap / Screenzap.c < prev    next >
C/C++ Source or Header  |  1988-10-02  |  2KB  |  90 lines

  1. /* ScreenZap.c 
  2. *  Clears away dead screens to regain chip ram and to clear the display.
  3. *  Written by Lars Clausen april 1988, placed in the Public Domain    */
  4.  
  5. #include <intuition/intuitionbase.h>
  6.  
  7. void *OpenWindow();
  8. void *GetMsg();
  9. void *OpenLibrary();
  10.  
  11. struct Window *w;
  12. struct IntuitionBase *IntuitionBase;
  13.  
  14. struct NewWindow nw =
  15. {
  16.    50,50,
  17.    295,50,
  18.    0,1,
  19.    CLOSEWINDOW | MOUSEBUTTONS,
  20.    WINDOWCLOSE | ACTIVATE | WINDOWDEPTH | WINDOWDRAG | SMART_REFRESH | NOCAREREFRESH,
  21.    NULL,NULL,(UBYTE *)"Click In Window To Proceed",
  22.    NULL, NULL,295,50,295,50,WBENCHSCREEN
  23. };
  24.  
  25. OpenIt()
  26. {
  27.    IntuitionBase = OpenLibrary("intuition.library",0L);
  28.    if (IntuitionBase == 0)
  29.    {
  30.       printf("Not enough mem to open Intuition. Get some.\n");
  31.       exit(1);
  32.    }
  33.    w = OpenWindow(&nw);
  34.    if (w == 0)
  35.    {
  36.       printf("No space for opening window. Clean up your memory.\n");
  37.       exit(2);
  38.    }
  39. }
  40.  
  41. Closer()
  42. {
  43.    struct Screen *Curs,*Nexts;
  44.    struct Window *Curw,*Nextw;
  45.    int x,y;
  46.  
  47.    Curs = w->WScreen;
  48.    Curs = Curs->NextScreen;
  49.    printf("FIRE!\n");
  50.    for (x=0; Curs!=NULL; x++)
  51.    {
  52.       if (Curs->FirstWindow!=NULL)
  53.       {
  54.          for (Curw=Curs->FirstWindow;Curw->NextWindow!=NULL;Curw=Curs->FirstWindow)
  55.          {
  56.             for (;Curw->NextWindow!=NULL; Curw=Curw->NextWindow);
  57.             CloseWindow(Curw);
  58.             printf("Bang!  ");
  59.          }
  60.          CloseWindow(Curw);
  61.          printf("Bang!  All windows in screen %d dead.\n",x);
  62.       }
  63.       Nexts = Curs->NextScreen;
  64.       CloseScreen(Curs);
  65.       printf("BUMMM...\n");
  66.       Curs = Nexts;
  67.    }
  68.    return(x);
  69. }
  70.  
  71. main(argc,argv)
  72. int argc; char **argv;
  73. {
  74.    struct IntuiMessage *msg;
  75.  
  76.    OpenIt();
  77.    WaitPort(w->UserPort);
  78.    msg = GetMsg(w->UserPort);
  79.    if (msg->Class == MOUSEBUTTONS)
  80.    {
  81.       printf("Reporting: %d screens killed\n",Closer());
  82.       if (argc == 0) /* WB startup, let the user read the kill # */ {
  83.          printf("Press return to exit.\n");
  84.          gets();
  85.       }
  86.    }
  87.    CloseWindow(w);
  88.    CloseLibrary(IntuitionBase);
  89. }
  90.