/*
$Log: progrunx.c $
*/

/* This code can be used as a direct replacement for the standard progrun.obj
   in 16 bit or 32 bit Windows programs. It allows you to tailor the size
   and frame of the PROGRUN window. */

#define WIN32_LEAN_AND_MEAN
/* Turn off warnings from Windows header files */
#pragma warning(disable:4201 4214 4514)
#include <windows.h>
#include "datafit.h"
#include "cexits.h"

extern int Qtitle_map;

void process()
{
  HWND hWnd = (HWND) trm_get_hwnd();
  LONG style = GetWindowLong(hWnd,GWL_STYLE);

  /* Change the bits set off in the style to suit your preferences */
  SetWindowLong(hWnd,GWL_STYLE,style & ~
               (WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SIZEBOX /* Various boxes */
                |WS_SYSMENU /* System menu */
                |WS_CAPTION /* Title bar */
                |WS_BORDER /* Border */
               ));
  SetWindowPos(hWnd,0,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_DRAWFRAME);
  /* Make the window go full screen */
  ShowWindow(hWnd,SW_SHOWMAXIMIZED);

  Qab_init();
  map_load("progmake");
  map_datamap(Qtitle_map);

  if (tail_found("help"))
  {
    field_help(Qtitle_map,3,HT_PAUSE);
    dp4_halt(1);
  }
  
  open_database(Qtitle_map,1,SHARED|QUIT_ON_FAILURE|MISSING_OK|READ_ONLY);
  Qload_dbnr = db_nr;

  {
    char *s;
    
    if ((s = tail_get_option("datadb",TRUE)) != 0)
      db_open(s,0,SHARED|QUIT_ON_FAILURE);
  }

  db_generation = db_get_generation();
  Qaction_program(tail_get_option("prog",TRUE));

}

/**/

void finish()
{
  if (db_nr != -1)
    db_close();
}

