#include "pch.hpp"
//===========================================================================//
// File:	 DirectDraw.cpp													 //
// Project:  GameOS					                                         //
// Contents: Interface to DirectDraw										 //
//---------------------------------------------------------------------------//
// Date      Who    Modification                                             //
// 01/21/98  AG     Created													 //
//---------------------------------------------------------------------------//
// Copyright (C) 1999 Microsoft Corp.						                 //
// All Rights reserved worldwide                                             //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL               //
//===========================================================================//
#include "ErrorHandler.hpp"
#include "DirectXDebugging.hpp"
#include "Windows.hpp"


HRESULT wDirectDrawCreateEx( GUID* lpGUID, void** lplpDD, REFIID iid, IUnknown* pUnkOuter )
{
	SPEW(( GROUP_DIRECTDRAW, "DirectDrawCreateEx()+",(int)lpGUID));

	HRESULT result=_DirectDrawCreateEx( lpGUID, lplpDD, iid, pUnkOuter );

	SPEW(( GROUP_DIRECTDRAW, " -0x%x",(int)*lplpDD));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - DirectDrawCreateEx(0x%x)",result,ErrorNumberToMessage(result),(int)lpGUID));

	return result;
}

HRESULT wDirectDrawEnumerate( LPDDENUMCALLBACK lpCallback,LPDDENUMCALLBACKEX lpCallbackEx,LPVOID lpContext )
{
	HRESULT result;
	if (_DirectDrawEnumerateEx)
	{
		SPEW(( GROUP_DIRECTDRAW, "DirectDrawEnumerateEx()" ));
		result=_DirectDrawEnumerateEx( lpCallbackEx, lpContext, DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_DETACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES );
	}
	else
	{
		SPEW(( GROUP_DIRECTDRAW, "DirectDrawEnumerate()" ));
		result=_DirectDrawEnumerate( lpCallback, lpContext );
	}

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - DirectDrawEnumerate()",result,ErrorNumberToMessage(result)));

	return result;
}

HRESULT wSetHWnd( LPDIRECTDRAWCLIPPER lpddc, DWORD dwFlags, HWND hWnd )
{
	SPEW(( GROUP_DIRECTDRAW, "SetHWnd(Flags=0x%x Window=0x%x)",(int)dwFlags,(int)hWnd ));

	HRESULT result=lpddc->SetHWnd( dwFlags, hWnd );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - SetHWnd(Flags=0x%x Window=0x%x)",result,ErrorNumberToMessage(result),(int)dwFlags,(int)hWnd ));

	return result;
} 


//
// IDirectDraw7
//
HRESULT wGetAvailableVidMem( IDirectDraw7* lpdd7, LPDDSCAPS2 lpDDSCaps2, LPDWORD lpdwTotal, LPDWORD lpdwFree )
{
	SPEW(( GROUP_DIRECTDRAW, "GetAvailableVidMem( 0x%x,%s)+",(int)lpdd7,GetSurfaceCaps(lpDDSCaps2) ));

	HRESULT result=lpdd7->GetAvailableVidMem( lpDDSCaps2, lpdwTotal, lpdwFree );

	SPEW(( GROUP_DIRECTDRAW, " -Total=%d, Free=%d",(int)*lpdwTotal,(int)*lpdwFree));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetAvailableVidMem( 0x%x,%s)",result,ErrorNumberToMessage(result),(int)lpdd7,GetSurfaceCaps(lpDDSCaps2) ));

	return result;
}

HRESULT wGetFourCCCodes( IDirectDraw7* lpdd7, LPDWORD lpNumCodes, LPDWORD lpCodes )
{
	SPEW(( GROUP_DIRECTDRAW, "GetFourCCCodes(0x%x)",(int)lpdd7));

	HRESULT result=lpdd7->GetFourCCCodes( lpNumCodes, lpCodes );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetFourCCCodes(0x%x)",result,ErrorNumberToMessage(result),(int)lpdd7));

	return result;
}

HRESULT wGetDeviceIdentifier( IDirectDraw7* lpdd7, LPDDDEVICEIDENTIFIER2 lpdddi2, DWORD dwFlags )
{
	SPEW(( GROUP_DIRECTDRAW, "GetDeviceIdentifier(0x%x)",(int)lpdd7));

	HRESULT result=lpdd7->GetDeviceIdentifier( lpdddi2, dwFlags );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetDeviceIdentifier(0x%x)",result,ErrorNumberToMessage(result),(int)lpdd7));

	return result;
}

HRESULT wGetCaps( IDirectDraw7* lpdd7, LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps )
{
	SPEW(( GROUP_DIRECTDRAW, "GetCaps(0x%x)",(int)lpdd7));

	HRESULT result=lpdd7->GetCaps( lpDDDriverCaps, lpDDHELCaps );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetCaps(0x%x)",result,ErrorNumberToMessage(result),(int)lpdd7));

	return result;
}

HRESULT wCreatePalette( IDirectDraw7* lpdd7,DWORD dwFlags,LPPALETTEENTRY lpColorTable, LPDIRECTDRAWPALETTE* lplpDDPalette, IUnknown* pUnkOuter )
{
	SPEW(( GROUP_DIRECTDRAW, "CreatePalette(%s)+",GetCreatePaletteFlags(dwFlags)));

	HRESULT result=lpdd7->CreatePalette( dwFlags, lpColorTable, lplpDDPalette, pUnkOuter );

	SPEW(( GROUP_DIRECTDRAW, " -0x%x",(int)*lplpDDPalette));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - CreatePalette(%s)",result,ErrorNumberToMessage(result),GetCreatePaletteFlags(dwFlags)));

	return result;
}

HRESULT wEnumDisplayModes( IDirectDraw7* lpdd7, DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext,LPDDENUMMODESCALLBACK2 lpEnumModesCallback )
{
	SPEW(( GROUP_DIRECTDRAW, "EnumDisplayModes( %s)",GetEnumDisplayModeFlags(dwFlags)));

	HRESULT result=lpdd7->EnumDisplayModes( dwFlags,lpDDSurfaceDesc,lpContext,lpEnumModesCallback );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - EnumDisplayModes( %s)",result,ErrorNumberToMessage(result),GetEnumDisplayModeFlags(dwFlags)));

	return result;
}

HRESULT wGetDisplayMode( IDirectDraw7* lpdd7, LPDDSURFACEDESC2 lpDDSurfaceDesc )
{
	SPEW(( GROUP_DIRECTDRAW, "GetDisplayMode()" ));

	HRESULT result=lpdd7->GetDisplayMode( lpDDSurfaceDesc );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetDisplayMode()",result,ErrorNumberToMessage(result)));

	return result;
}

HRESULT wSetDisplayMode( IDirectDraw7* lpdd7,DWORD dwWidth,DWORD dwHeight,DWORD dwBPP,DWORD dwRefreshRate,DWORD dwFlags )
{
	SPEW(( GROUP_DIRECTDRAW, "SetDisplayMode(%dx%d %dbpp %dHz)",dwWidth,dwHeight,dwBPP,dwRefreshRate));

	HRESULT result=lpdd7->SetDisplayMode( dwWidth,dwHeight,dwBPP,dwRefreshRate,dwFlags );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - SetDisplayMode(%dx%d %dbpp %dHz)",result,ErrorNumberToMessage(result),dwWidth,dwHeight,dwBPP,dwRefreshRate));

	return result;
}

HRESULT wRestoreDisplayMode( IDirectDraw7* lpdd7)
{
	SPEW(( GROUP_DIRECTDRAW, "RestoreDisplayMode()" ));

	HRESULT result=lpdd7->RestoreDisplayMode();

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - RestoreDisplayMode()",result,ErrorNumberToMessage(result) ));

	return result;
}

HRESULT wCreateClipper( IDirectDraw7* lpdd7, DWORD dwFlags, LPDIRECTDRAWCLIPPER* lplpDDClipper, IUnknown* pUnkOuter )
{
	SPEW(( GROUP_DIRECTDRAW, "CreateClipper()+"));

	HRESULT result=lpdd7->CreateClipper( dwFlags,lplpDDClipper,pUnkOuter );

	SPEW(( GROUP_DIRECTDRAW, " -0x%x",(int)*lplpDDClipper));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - CreateClipper()",result,ErrorNumberToMessage(result)));

	return result;
}

HRESULT wCreateSurface( IDirectDraw7* lpdd7, LPDDSURFACEDESC2 lpDDSurfaceDesc, IDirectDrawSurface7** lplpDDSurface7, IUnknown* pUnkOuter )
{
	SPEW(( GROUP_DIRECTDRAW, "CreateSurface( 0x%x:%s)+",(int)lpdd7,GetSurfaceDescription(lpDDSurfaceDesc) ));

	HRESULT result=lpdd7->CreateSurface( lpDDSurfaceDesc, lplpDDSurface7, pUnkOuter );

	SPEW(( GROUP_DIRECTDRAW, " -0x%x",(int)*lplpDDSurface7));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - CreateSurface( 0x%x:%s)",result,ErrorNumberToMessage(result),(int)lpdd7,GetSurfaceDescription(lpDDSurfaceDesc) ));

	return result;
}

HRESULT wSetCooperativeLevel( IDirectDraw7* lpdd7, HWND hWnd, DWORD dwFlags )
{
	SPEW(( GROUP_DIRECTDRAW, "SetCooperativeLevel( 0x%x,%s)",(int)lpdd7,GetSetCooperativeLevelFlags(dwFlags) ));

	HRESULT result=lpdd7->SetCooperativeLevel( hWnd, dwFlags );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - SetCooperativeLevel( 0x%x,%s)",result,ErrorNumberToMessage(result),(int)lpdd7,GetSetCooperativeLevelFlags(dwFlags) ));

	return result;
}



//
// IDirectDrawSurface7
//
HRESULT wIsLost( IDirectDrawSurface7* lpdds7 )
{
	SPEW(( GROUP_DIRECTDRAW, "IsLost(0x%x)+",(int)lpdds7));

	HRESULT result=lpdds7->IsLost();

	SPEW(( GROUP_DIRECTDRAW, " -(%s)",(DDERR_SURFACELOST==result ? "Yes" : "No") ));

	if( FAILED(result) && result!=DDERR_SURFACELOST )
		PAUSE(( "FAILED (0x%x - %s) - IsLost(0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7));

	return result;
}

HRESULT wGetDC( IDirectDrawSurface7* lpdds7, HDC* lphDC )
{
	SPEW(( GROUP_DIRECTDRAW, "GetDC(0x%x)+",(int)lpdds7));

	HRESULT result=lpdds7->GetDC( lphDC );

	SPEW(( GROUP_DIRECTDRAW, " -0x%x",(int)*lphDC));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetDC(0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7));

	return result;
}
HRESULT wReleaseDC( IDirectDrawSurface7* lpdds7, HDC hDC )
{
	SPEW(( GROUP_DIRECTDRAW, "ReleaseDC(0x%x, 0x%x)",(int)lpdds7,(int)hDC ));

	HRESULT result=lpdds7->ReleaseDC( hDC );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - ReleaseDC(0x%x, 0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7,(int)hDC));

	return result;
}

HRESULT wSetColorKey( IDirectDrawSurface7* lpdds7, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey )
{
	SPEW(( GROUP_DIRECTDRAW, "SetColorKey(0x%x,%s(0x%x,0x%x))",(int)lpdds7,GetSetColorKeyFlags(dwFlags),lpDDColorKey->dwColorSpaceLowValue,lpDDColorKey->dwColorSpaceHighValue ));

	HRESULT result=lpdds7->SetColorKey( dwFlags, lpDDColorKey );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - SetColorKey(0x%x,%s(0x%x,0x%x))",result,ErrorNumberToMessage(result),(int)lpdds7,GetSetColorKeyFlags(dwFlags),lpDDColorKey->dwColorSpaceLowValue,lpDDColorKey->dwColorSpaceHighValue ));

	return result;
}

HRESULT wLock( IDirectDrawSurface7* lpdds7, LPRECT lpDestRect, LPDDSURFACEDESC2 lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent )
{
	SPEW(( GROUP_DIRECTDRAW, "Lock(0x%x,%s)",(int)lpdds7,GetLockFlags(dwFlags)));

	HRESULT result=lpdds7->Lock( lpDestRect, lpDDSurfaceDesc, dwFlags, hEvent );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - Lock(0x%x,%s)",result,ErrorNumberToMessage(result),(int)lpdds7,GetLockFlags(dwFlags)));

	return result;
}

HRESULT wUnlock( IDirectDrawSurface7* lpdds7, LPRECT lprect )
{
	char Buffer[128];
	SPEW(( GROUP_DIRECTDRAW, "Unlock(0x%x,%s)",(int)lpdds7,GetRectangle(Buffer,lprect) ));

	HRESULT result=lpdds7->Unlock( lprect );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - Unlock(0x%x,%s)",result,ErrorNumberToMessage(result),(int)lpdds7,GetRectangle(Buffer,lprect) ));

	return result;
}

HRESULT wLock( IDirectDrawSurface* lpdds, LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent )
{
	SPEW(( GROUP_DIRECTDRAW, "Lock(0x%x,%s)",(int)lpdds,GetLockFlags(dwFlags)));

	HRESULT result=lpdds->Lock( lpDestRect, lpDDSurfaceDesc, dwFlags, hEvent );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - Lock(0x%x,%s)",result,ErrorNumberToMessage(result),(int)lpdds,GetLockFlags(dwFlags)));

	return result;
}

HRESULT wUnlock( IDirectDrawSurface* lpdds, LPRECT lprect )
{
	char Buffer[128];
	SPEW(( GROUP_DIRECTDRAW, "Unlock(0x%x,%s)",(int)lpdds,GetRectangle(Buffer,lprect) ));

	HRESULT result=lpdds->Unlock( lprect );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - Unlock(0x%x,%s)",result,ErrorNumberToMessage(result),(int)lpdds,GetRectangle(Buffer,lprect) ));

	return result;
}

HRESULT wSetPalette( IDirectDrawSurface7* lpdds7, LPDIRECTDRAWPALETTE lpDDPalette )
{
	SPEW(( GROUP_DIRECTDRAW, "SetPalette(0x%x,0x%x)",(int)lpdds7,(int)lpDDPalette ));

	HRESULT result=lpdds7->SetPalette( lpDDPalette );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - SetPalette(0x%x,0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7,(int)lpDDPalette ));

	return result;
}

HRESULT wRestore( IDirectDrawSurface7* lpdds7 )
{
	SPEW(( GROUP_DIRECTDRAW, "Restore(0x%x)",(int)lpdds7 ));

	HRESULT result=lpdds7->Restore();

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - Restore(0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7 ));

	return result;
}
 
HRESULT wBlt( IDirectDrawSurface7* lpdds7, LPRECT lpDestRect, IDirectDrawSurface7* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx )
{
	SPEW(( GROUP_DIRECTDRAW, "Blt(%s)",GetBltInformation(lpdds7,lpDestRect,lpDDSrcSurface,lpSrcRect,dwFlags,lpDDBltFx) ));

	HRESULT result=lpdds7->Blt( lpDestRect,lpDDSrcSurface,lpSrcRect,dwFlags,lpDDBltFx );

	if( FAILED(result) && result!=DDERR_SURFACELOST )
		PAUSE(( "FAILED (0x%x - %s) - Blt(%s)",result,ErrorNumberToMessage(result),GetBltInformation(lpdds7,lpDestRect,lpDDSrcSurface,lpSrcRect,dwFlags,lpDDBltFx)));

	return result;
}

HRESULT wBltFast( IDirectDrawSurface7* lpdds7, DWORD dwX, DWORD dwY, IDirectDrawSurface7* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans )
{
	SPEW(( GROUP_DIRECTDRAW, "BltFast(%s)",GetBltFastInformation(lpdds7,dwX,dwY,lpDDSrcSurface,lpSrcRect,dwTrans)));

	HRESULT result=lpdds7->BltFast( dwX,dwY,lpDDSrcSurface,lpSrcRect,dwTrans );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - BltFast(%s)",result,ErrorNumberToMessage(result),GetBltFastInformation(lpdds7,dwX,dwY,lpDDSrcSurface,lpSrcRect,dwTrans)));

	return result;
}

HRESULT wFlip( IDirectDrawSurface7* lpdds7, IDirectDrawSurface7* lpDDSurfaceTargetOverride, DWORD dwFlags )
{
	SPEW(( GROUP_DIRECTDRAW, "Flip( 0x%x,0x%x,%s)",(int)lpdds7,(int)lpDDSurfaceTargetOverride,GetFlipFlags(dwFlags) ));

	HRESULT result=lpdds7->Flip( lpDDSurfaceTargetOverride, dwFlags );

	if( FAILED(result) && result!=DDERR_SURFACELOST )
		PAUSE(( "FAILED (0x%x - %s) - Flip( 0x%x,0x%x,%s)",result,ErrorNumberToMessage(result),(int)lpdds7,(int)lpDDSurfaceTargetOverride,GetFlipFlags(dwFlags) ));

	return result;
}

HRESULT wGetSurfaceDesc( IDirectDrawSurface7* lpdds7, LPDDSURFACEDESC2 lpDDSurfaceDesc )
{
	SPEW(( GROUP_DIRECTDRAW, "GetSurfaceDesc(0x%x)+",(int)lpdds7 ));

	HRESULT result=lpdds7->GetSurfaceDesc( lpDDSurfaceDesc );

	SPEW(( GROUP_DIRECTDRAW, " -( %s)",GetSurfaceDescription(lpDDSurfaceDesc)));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetSurfaceDesc(0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7 ));

	return result;
}

HRESULT wGetSurfaceDesc( IDirectDrawSurface* lpdds, LPDDSURFACEDESC lpDDSurfaceDesc )
{
	SPEW(( GROUP_DIRECTDRAW, "GetSurfaceDesc(0x%x)+",(int)lpdds ));

	HRESULT result=lpdds->GetSurfaceDesc( lpDDSurfaceDesc );

	SPEW(( GROUP_DIRECTDRAW, " -( %s)",GetSurfaceDescriptionOld(lpDDSurfaceDesc)));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetSurfaceDesc(0x%x)",result,ErrorNumberToMessage(result),(int)lpdds ));

	return result;
}

HRESULT wGetPixelFormat( IDirectDrawSurface7* lpdds7, LPDDPIXELFORMAT lpDDPixelFormat )
{
	SPEW(( GROUP_DIRECTDRAW, "GetPixelFormat(0x%x)+",(int)lpdds7 ));

	HRESULT result=lpdds7->GetPixelFormat( lpDDPixelFormat );

	SPEW(( GROUP_DIRECTDRAW, " -( %s)",GetGosPixelFormat(lpDDPixelFormat)));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetPixelFormat(0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7 ));

	return result;
}

HRESULT wGetAttachedSurface( IDirectDrawSurface7* lpdds7, LPDDSCAPS2 lpDDSCaps2, IDirectDrawSurface7** lplpDDAttachedSurface )
{
	SPEW(( GROUP_DIRECTDRAW, "GetAttachedSurface(0x%x)+",(int)lpdds7 ));

	HRESULT result=lpdds7->GetAttachedSurface( lpDDSCaps2, lplpDDAttachedSurface );

	SPEW(( GROUP_DIRECTDRAW, " -0x%x",(int)*lplpDDAttachedSurface));

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - GetAttachedSurface(0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7 ));

	return result;
}

HRESULT wAddAttachedSurface( IDirectDrawSurface7* lpdds7, IDirectDrawSurface7* lpDDSAttachedSurface )
{
	SPEW(( GROUP_DIRECTDRAW, "AddAttachedSurface(0x%x,0x%x)",(int)lpdds7,(int)lpDDSAttachedSurface ));

	HRESULT result=lpdds7->AddAttachedSurface( lpDDSAttachedSurface );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - AddAttachedSurface(0x%x- 0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7,(int)lpDDSAttachedSurface ));

	return result;
}

HRESULT wDeleteAttachedSurface( IDirectDrawSurface7* lpdds7, DWORD dwFlags, IDirectDrawSurface7* lpDDSAttachedSurface )
{
	SPEW(( GROUP_DIRECTDRAW, "DeleteAttachedSurface(0x%x,0x%x)",(int)lpdds7,(int)lpDDSAttachedSurface ));

	HRESULT result=lpdds7->DeleteAttachedSurface( dwFlags, lpDDSAttachedSurface );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - DeleteAttachedSurface(0x%x,0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7,(int)lpDDSAttachedSurface ));

	return result;
}

HRESULT wSetClipper( IDirectDrawSurface7* lpdds7, LPDIRECTDRAWCLIPPER lpDDClipper )
{
	SPEW(( GROUP_DIRECTDRAW, "SetClipper(0x%x,0x%x)",(int)lpdds7,(int)lpDDClipper ));

	HRESULT result=lpdds7->SetClipper( lpDDClipper );

	if( FAILED(result) )
		PAUSE(( "FAILED (0x%x - %s) - SetClipper(0x%x- 0x%x)",result,ErrorNumberToMessage(result),(int)lpdds7,(int)lpDDClipper ));

	return result;
}






