MONITOR.H

/*========================================================================== 
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: monitor.h
*
*@@BEGIN_MSINTERNAL
* History:
* Date By Reason
* ==== == ======
* 15-sep-97 t-craigs Created
*@@END_MSINTERNAL
*
***************************************************************************/


#ifndef MONITOR_H
#define MONITOR_H

#undef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>

#include "multimon.h"// make sure to include this before ddraw.h for multimon
#include <ddraw.h>

#include "resource.h"
#include "ddutil.h"

//
// The CMonitor class encapsulates basic functionality
// for programming graphical display output.
// It is multimonitor aware and DirectDraw enabled.
//
// The static Initialize routine assumes the existance
// of a global array of CMonitor objects, and employs the new
// DirectDrawEnumerateEx fct. to set up descriptive data structures.
//
// CMonitor also supports a bare-bones DirectDraw framework:
// an IDirectDraw interface and an IDirectDrawSurface primary
// surface with one back buffer. The three surface-related
// functions (DDInit, RestoreSurfaces, and Release) are virtual
// to allow a derived class to support any number of
// additional surfaces while remaining compatible with the
// generic Blank and Flip routines.
//
class CMonitor
{
public:
CMonitor();
~CMonitor();

static intiNumberOfMonitors;

// Initializes the common data of global Monitor array
static HRESULTInitialize();

// Uninitializes all monitors in the global Monitor array
static voidUninit();

// Basic DirectDraw initialization
virtual HRESULTDDInit( HWND hWnd, BOOL bEnableMultiMon );

// Restores the primary surface
virtual HRESULT RestoreSurfaces();

// Releases the primary surface and DirectDraw object
virtual voidRelease();

// Fills the back buffer with the specified color
HRESULTBlank( DWORD dwFillColor );

// Flips the back buffer to the front buffer
HRESULTFlip();

// descriptive data structures
HMONITORhMonitor;
GUID*lpGUID;
MONITORINFOEXMonitorInfo;
LPRECTlpMonitorRect;
DWORDdwWidth;
DWORDdwHeight;
DWORDScreenBpp;

// use this to return detailed error messages
charszErrMsg[256];

// DDraw interface pointers
LPDIRECTDRAW lpDD;
LPDIRECTDRAWSURFACE lpFrontBuffer;
LPDIRECTDRAWSURFACE lpBackBuffer;
};


typedef struct {
RGNDATAHEADER hdr;
RECT rgndata[4];
} CLIPLIST, *LPCLIPLIST;


//
// The CMyMonitor derives from CMonitor and builds
// upon that foundation to implement additional graphical
// display functionality specific to this application (Donuts2).
//
// The Initialize routine now calculates the monitor boundary
// locations where there is monitor adjacency as defined in
// the Display/Settings tab of the Control Panel, and DrawBorder
// displays a white line around the monitor edges except at
// these points of adjacency.
//
// DDInit, RestoreSurfaces, and Release have been extended to
// support all the off-screen sprite bitmaps.
//
class CMyMonitor : public CMonitor
{
public:
CMyMonitor();

static DWORD dwFillColor;

static HRESULT Initialize();
static voidUninit();

virtual HRESULTDDInit( HWND hwnd, BOOL bEnableMultiMon );
virtual HRESULT RestoreSurfaces();
virtual voidRelease();

HRESULTBlank();
HRESULTDrawBorder();

// data
intiNumLines;
RECTLine[9];

// more DDraw objects
CLIPLISTClipList;
LPDIRECTDRAWSURFACE lpDonut;
LPDIRECTDRAWSURFACE lpPyramid;
LPDIRECTDRAWSURFACE lpCube;
LPDIRECTDRAWSURFACE lpSphere;
LPDIRECTDRAWSURFACE lpShip;
LPDIRECTDRAWSURFACE lpNum;
LPDIRECTDRAWPALETTE lpArtPalette;
LPDIRECTDRAWPALETTE lpSplashPalette;
LPDIRECTDRAWCLIPPER lpDDClipper;
LPDIRECTDRAWSURFACElpBackground;
};

#endif