/*********************** iconify ************************\
 *    Written by Syd L. Bolton ©1991 Legendary Design   *
 *      Module for ScreenMod ... Date: May 2, 1991      *
\********************************************************/

#include "iconify.h"

iconify()
{
struct Window *IWindow;
struct IntuiMessage *message;
ULONG class;
int icon_exit=0;

if (Window) ClearMenuStrip(Window);
if (Window) CloseWindow(Window);
if (Screen) CloseScreen(Screen);    /* this finishes off main program */

IWindow=OpenWindow(&IconWindow);
if (IWindow==NULL) {
	puts("Couldn't open tiny window!!!");
	exit(1);
	}
	
/* now sleep until something happens ... */

do {
	WaitPort(IWindow->UserPort);
		while ( ( message=(struct IntuiMessage *)
			GetMsg(IWindow->UserPort) ) != NULL)
		{
		class=message->Class;
		ReplyMsg(message);

		if (class==MOUSEBUTTONS) icon_exit=1;
		if (class==CLOSEWINDOW) icon_exit=2;
		}
	} while (icon_exit==0);

CloseWindow(IWindow);

if (icon_exit==2) {
	if (GfxBase) CloseLibrary(GfxBase);
	if (IntuitionBase) CloseLibrary(IntuitionBase);
	exit(1);
	}

opendisplay();
screenlist();
scr=0;
updatestats();

return(0);
}

