/*
*********************************************************************
*
*	The Essence of OLE
*
*	Source code sample
*
*	Copyright (c) 1996, Rolling Thunder Computing, Ipswich MA
*
*	e-mail: essence@rollthunder.com
*	CompuServe: 73540,3430
*	Web: http://www.rollthunder.com
*
*	File Name: WINMAIN.CPP
*
*	Purpose: Entry point for moniker client sample
*
*********************************************************************
*/

#include	<windows.h>

/*
*****************************************************************************
Application header files
*****************************************************************************
*/


#include "main.h"

/*
*****************************************************************************
Function prototype files
*****************************************************************************
*/


/*
*****************************************************************************
Global Variables defined here
*****************************************************************************
*/


HINSTANCE hInst;
HWND  hMainWnd ;


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
	LPSTR lpCmdLine, int nCmdShow)
{
    MSG msg;
    WNDCLASS  wc;
 	
	hInst = hInstance ;
	TCHAR *Class = TEXT("Ole Demo") ;
	
/*
Initialize Ole 2.0 Libraries
*/

	HRESULT hr = OleInitialize (NULL) ;

/*
Initialize window classes, exits if it can't
First for the main window
*/

	wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW; 			
    wc.lpfnWndProc = MainWndProc;       
    wc.cbClsExtra = 0;                
    wc.cbWndExtra = 0;               
    wc.hInstance = hInst;          
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = GetStockObject(WHITE_BRUSH);
    wc.lpszMenuName =  TEXT("MainMenu");  
    wc.lpszClassName = Class; 

	RegisterClass(&wc) ;


/*
Create a main window for this application instance.
Position and size it as it was the last time it was shut down with SAVE
CHANGES checked
If window could not be created, return "failure"
*/



    hMainWnd = CreateWindow(
        Class,                    
        TEXT("Essence of OLE Monikercl.exe"),     
        WS_OVERLAPPEDWINDOW ,         
	 	CW_USEDEFAULT,  
	 	CW_USEDEFAULT,   
	 	400,   
	 	200,
	 	NULL,                          
        NULL,                          
        hInst,	                
        NULL                            
    );




/*
Make main window visible; update its client area
Zoom if was zoomed last time changes were saved
*/

    ShowWindow(hMainWnd, nCmdShow);             


/*
Acquire and dispatch messages until a WM_QUIT message is received.
*/

	 while (GetMessage(&msg,	  
	    NULL,							   
	    NULL,		   				
	    NULL))		   				
	{
	 	TranslateMessage(&msg);	  
		DispatchMessage(&msg);	   
	}


/*
Shut down OLE libraries
*/

	OleUninitialize ( ) ;


/*
Finished with WinSv application.  Return value from PostQuitMessage
*/                                  


	 return (msg.wParam);

}

