//==============================================================================
// 04_RegisterClass.c
//
// New Entities:
// - structure WNDCLASS
// - function RegisterClass
// - callback function WndProc
// - function DefWindowProc
//==============================================================================
#include <windows.h>

long FAR PASCAL _export WndProc (HWND, UINT, UINT, LONG) ;

int PASCAL WinMain (HINSTANCE hInstance,
                    HINSTANCE hPrevInst,
                    LPSTR lpszCP,
                    int nCS)
{
  HWND        hwnd;
  WNDCLASS    wndclass;

  wndclass.style         = CS_GLOBALCLASS; //
  wndclass.lpfnWndProc   = WndProc;        //
  wndclass.cbClsExtra    = 0;              //
  wndclass.cbWndExtra    = 0;              //
  wndclass.hInstance     = hInstance;      //
  wndclass.hIcon         = NULL;           //
  wndclass.hCursor       = NULL;           //
  wndclass.hbrBackground = NULL;           //
  wndclass.lpszMenuName  = NULL;           //
  wndclass.lpszClassName = "WinClass";     //

  RegisterClass (&wndclass) ;

  hwnd = CreateWindow(
		                 "WinClass",  // window class name
		                 "Test",      // window caption
                     WS_VISIBLE,  // window style
                     0,           // initial x position
                     0,           // initial y position
                     300,         // initial x size
                     300,         // initial y size
                     NULL,        // parent window handle
                     NULL,        // window menu handle
                     hInstance,   // program instance handle
		                 NULL) ;		  // creation parameters

  MessageBox(NULL, "Finish program?", "Window Created", MB_OK);

  return 0 ;
}

//---------------------------------------------------------------------------
long FAR PASCAL _export WndProc(HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
  return DefWindowProc (hwnd, message, wParam, lParam) ;
}
