#include "windows.h" //for GetMessage function, etc
#include <ctime> //for time function
#include <cstdlib> //for srand function
#include "ifschooserwindow.hpp" //for TIFSChooserWindow type
#include "graphwindow.hpp" //for TGraphWindow type
#include "draw2difs.hpp" //for LoopDraw2DIFS function pointer

//Message Loop.

int MessageLoop()
{
 BOOL MsgReturn;
 MSG msg;

 while ((MsgReturn = GetMessage(&msg, NULL, 0, 0)) != 0)
 {
  if (MsgReturn == -1)
  {
  }
  else
  {
   TranslateMessage(&msg);
   DispatchMessage(&msg);
  }
 }

 return (int) msg.wParam;
}

//Entry Point.

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
 TIFSChooserWindow *IFSChooserWindow;
 TGraphWindow *IFSDisplayerWindow;
 int ReturnValue;

 IFSChooserWindow = new TIFSChooserWindow(hInstance, nCmdShow, "IFS Chooser");
 IFSDisplayerWindow = new TGraphWindow(hInstance, LoopDraw2DIFS, (void *) IFSChooserWindow->ReadOnlyIFS, IFSChooserWindow->GetMergePaintEvent(), IFSChooserWindow->GetRePaintEvent(), 2, 2, nCmdShow, "IFS Displayer");

 IFSChooserWindow->BringToTop();
 IFSChooserWindow->SetProgressPtr(&(IFSDisplayerWindow->PaintProgress));

 srand((unsigned) time(NULL)); //King p190

 ReturnValue = MessageLoop();

 delete IFSDisplayerWindow;
 delete IFSChooserWindow;

 return ReturnValue;
}
