{***********************************************************************}
{									}
{ __InitWin   Initialize window descriptor list 			}
{									}
{ procedure __InitWin;							}
{									}
{ Description The pointer to the window descriptor list is initialized	}
{	      in the Unit_Win initialization code.  This procedure	}
{	      clears the entire window descriptor list. 		}
{									}
{	      Normally, there is no reason to call __InitWin directly,	}
{	      but it can be used conveniently to reset the window	}
{	      "system."  Notice, however, that __InitWin does not	}
{	      remove active screens from the physical screen.		}
{									}
{	      The other reason to call __InitWin directly is if you	}
{	      are designing a memory resident (or TSR) program		}
{	      that will 'pop up' upon invocation with a hot key 	}
{	      or a timer event.  In such a program, you will not know	}
{	      definitely the current state of the machine (video mode,	}
{	      number of text lines on screen, etc.) until the program	}
{	      is awakened.  In such a case, the best course is to build }
{	      your windows on the fly, first calling __RetDvScn to re-	}
{	      turn the current video mode and reset the Unit_Scn global }
{	      variables, then calling __InitWin.			}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

procedure __InitWin;

  var
    WinPtr,NextPtr : _WindowPtr;

  begin {__InitWin}

    { Begin by searching the window descriptor list, freeing all	}
    { allocated memory as it is found.					}

    WinPtr := _WinRoot;
    while (WinPtr <> NIL) do
      begin
	NextPtr := WinPtr^._WinTop;
	with WinPtr^ do
	  if (_Image <> NIL) then
	     FreeMem(_Image,_ImageSize);
	Dispose(WinPtr);
	WinPtr := NextPtr
      end;

    { Reset the current window, and the Turbo Pascal window to the full }
    { screen.								}

    with _CurWindow do
      begin
	_XUpper := 1;
	_YUpper := 1;
	_XLower := _CurColumns;
	_YLower := _CurRows
      end;
    WindMin  := 0;
    WindMax  := __2WordSup(_CurRows - 1,_CurColumns - 1);

    _WinRoot := NIL;		       { Initialize all pointers	}
    WinLast_ := NIL;
    _WinCur  := NIL

  end;	{__InitWin}
