#include "winspool.h"
#include "winerror.h"
#include "winreg.h"
+#include "wownt32.h"
#include "wine/debug.h"
#include "gdi.h"
#include "heap.h"
*/
INT WINAPI EndPage(HDC hdc)
{
+ ABORTPROC abort_proc;
INT ret = 0;
DC *dc = DC_GetDCPtr( hdc );
if(!dc) return SP_ERROR;
if (dc->funcs->pEndPage) ret = dc->funcs->pEndPage( dc->physDev );
+ abort_proc = dc->pAbortProc;
GDI_ReleaseObj( hdc );
- if (!QueryAbort16( hdc, 0 ))
+ if (abort_proc && !abort_proc( hdc, 0 ))
{
EndDoc( hdc );
ret = 0;
* TRUE if no AbortProc avail or AbortProc wants to continue printing.
* FALSE if AbortProc wants to abort printing.
*/
-BOOL16 WINAPI QueryAbort16(HDC16 hdc, INT16 reserved)
+BOOL16 WINAPI QueryAbort16(HDC16 hdc16, INT16 reserved)
{
BOOL ret = TRUE;
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCPtr( hdc );
ABORTPROC abproc;
if (!dc) return FALSE;
proc16 = dc->pAbortProc16;
GDI_ReleaseObj( hdc );
- if (proc16) return PRTDRV_CallTo16_word_ww( (FARPROC16)proc16, hdc, code );
+ if (proc16) return PRTDRV_CallTo16_word_ww( (FARPROC16)proc16, HDC_16(hdc), code );
return TRUE;
}
/**********************************************************************
* SetAbortProc (GDI.381)
*/
-INT16 WINAPI SetAbortProc16(HDC16 hdc, ABORTPROC16 abrtprc)
+INT16 WINAPI SetAbortProc16(HDC16 hdc16, ABORTPROC16 abrtprc)
{
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
/***********************************************************************
* SelectVisRgn (GDI.105)
*/
-INT16 WINAPI SelectVisRgn16( HDC16 hdc, HRGN16 hrgn )
+INT16 WINAPI SelectVisRgn16( HDC16 hdc16, HRGN16 hrgn )
{
int retval;
+ HDC hdc = HDC_32( hdc16 );
DC * dc;
if (!hrgn) return ERROR;
/***********************************************************************
* OffsetVisRgn (GDI.102)
*/
-INT16 WINAPI OffsetVisRgn16( HDC16 hdc, INT16 x, INT16 y )
+INT16 WINAPI OffsetVisRgn16( HDC16 hdc16, INT16 x, INT16 y )
{
INT16 retval;
+ HDC hdc = HDC_32( hdc16 );
DC * dc = DC_GetDCUpdate( hdc );
if (!dc) return ERROR;
TRACE("%04x %d,%d\n", hdc, x, y );
/***********************************************************************
* ExcludeVisRect (GDI.73)
*/
-INT16 WINAPI ExcludeVisRect16( HDC16 hdc, INT16 left, INT16 top,
- INT16 right, INT16 bottom )
+INT16 WINAPI ExcludeVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
{
HRGN tempRgn;
INT16 ret;
POINT pt[2];
+ HDC hdc = HDC_32( hdc16 );
DC * dc = DC_GetDCUpdate( hdc );
if (!dc) return ERROR;
/***********************************************************************
* IntersectVisRect (GDI.98)
*/
-INT16 WINAPI IntersectVisRect16( HDC16 hdc, INT16 left, INT16 top,
- INT16 right, INT16 bottom )
+INT16 WINAPI IntersectVisRect16( HDC16 hdc16, INT16 left, INT16 top, INT16 right, INT16 bottom )
{
HRGN tempRgn;
INT16 ret;
POINT pt[2];
+ HDC hdc = HDC_32( hdc16 );
DC * dc = DC_GetDCUpdate( hdc );
if (!dc) return ERROR;
/***********************************************************************
* SaveVisRgn (GDI.129)
*/
-HRGN16 WINAPI SaveVisRgn16( HDC16 hdc )
+HRGN16 WINAPI SaveVisRgn16( HDC16 hdc16 )
{
HRGN copy;
GDIOBJHDR *obj, *copyObj;
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCUpdate( hdc );
if (!dc) return 0;
return 0;
}
copyObj->hNext = obj->hNext;
- obj->hNext = copy;
+ obj->hNext = HRGN_16(copy);
GDI_ReleaseObj( copy );
GDI_ReleaseObj( dc->hVisRgn );
GDI_ReleaseObj( hdc );
- return copy;
+ return HRGN_16(copy);
}
/***********************************************************************
* RestoreVisRgn (GDI.130)
*/
-INT16 WINAPI RestoreVisRgn16( HDC16 hdc )
+INT16 WINAPI RestoreVisRgn16( HDC16 hdc16 )
{
HRGN saved;
GDIOBJHDR *obj, *savedObj;
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCPtr( hdc );
INT16 ret = ERROR;
TRACE("%04x\n", hdc );
if (!(obj = GDI_GetObjPtr( dc->hVisRgn, REGION_MAGIC ))) goto done;
- saved = obj->hNext;
+ saved = HRGN_32(obj->hNext);
if ((savedObj = GDI_GetObjPtr( saved, REGION_MAGIC )))
{
#include <stdlib.h>
#include <string.h>
-#include "gdi.h"
-#include "heap.h"
-#include "wine/debug.h"
-#include "font.h"
-#include "winerror.h"
#include "windef.h"
#include "wingdi.h"
+#include "winerror.h"
+#include "wownt32.h"
#include "wine/winuser16.h"
+#include "gdi.h"
+#include "heap.h"
+#include "font.h"
+#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dc);
HDC hdc;
DC *dc;
- if (!(dc = GDI_AllocObject( sizeof(*dc), DC_MAGIC, &hdc, &dc_funcs ))) return NULL;
+ if (!(dc = GDI_AllocObject( sizeof(*dc), DC_MAGIC, (HGDIOBJ*)&hdc, &dc_funcs ))) return NULL;
dc->hSelf = hdc;
dc->funcs = funcs;
{
DWORD data = dc->dwHookData;
GDI_ReleaseObj( hdc );
- proc( hdc, DCHC_INVALIDVISRGN, data, 0 );
+ proc( HDC_16(hdc), DCHC_INVALIDVISRGN, data, 0 );
if (!(dc = DC_GetDCPtr( hdc ))) break;
/* otherwise restart the loop in case it became dirty again in the meantime */
}
*/
void DC_InitDC( DC* dc )
{
- RealizeDefaultPalette16( dc->hSelf );
+ if (dc->funcs->pRealizeDefaultPalette) dc->funcs->pRealizeDefaultPalette( dc->physDev );
SetTextColor( dc->hSelf, dc->textColor );
SetBkColor( dc->hSelf, dc->backgroundColor );
SelectObject( dc->hSelf, dc->hPen );
/***********************************************************************
- * GetDCState (GDI.179)
+ * GetDCState (Not a Windows API)
*/
-HDC16 WINAPI GetDCState16( HDC16 hdc )
+HDC WINAPI GetDCState( HDC hdc )
{
DC * newdc, * dc;
HGDIOBJ handle;
/***********************************************************************
- * SetDCState (GDI.180)
+ * SetDCState (Not a Windows API)
*/
-void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
+void WINAPI SetDCState( HDC hdc, HDC hdcs )
{
DC *dc, *dcs;
}
+/***********************************************************************
+ * GetDCState (GDI.179)
+ */
+HDC16 WINAPI GetDCState16( HDC16 hdc )
+{
+ return HDC_16( GetDCState( HDC_32(hdc) ));
+}
+
+
+/***********************************************************************
+ * SetDCState (GDI.180)
+ */
+void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
+{
+ SetDCState( HDC_32(hdc), HDC_32(hdcs) );
+}
+
+
/***********************************************************************
* SaveDC (GDI32.@)
*/
return ret;
}
- if (!(hdcs = GetDCState16( hdc )))
+ if (!(hdcs = GetDCState( hdc )))
{
GDI_ReleaseObj( hdc );
return 0;
}
dcs->header.hNext = dc->header.hNext;
- dc->header.hNext = hdcs;
+ dc->header.hNext = HDC_16(hdcs);
TRACE("(%04x): returning %d\n", hdc, dc->saveLevel+1 );
ret = ++dc->saveLevel;
GDI_ReleaseObj( hdcs );
success=TRUE;
while (dc->saveLevel >= level)
{
- HDC16 hdcs = dc->header.hNext;
+ HDC hdcs = HDC_32(dc->header.hNext);
if (!(dcs = DC_GetDCPtr( hdcs )))
{
GDI_ReleaseObj( hdc );
dc->header.hNext = dcs->header.hNext;
if (--dc->saveLevel < level)
{
- SetDCState16( hdc, hdcs );
+ SetDCState( hdc, hdcs );
if (!PATH_AssignGdiPath( &dc->path, &dcs->path ))
/* FIXME: This might not be quite right, since we're
* returning FALSE but still destroying the saved DC state */
{
DWORD data = dc->dwHookData;
GDI_ReleaseObj( hdc );
- if (!proc( hdc, DCHC_DELETEDC, data, 0 )) return FALSE;
+ if (!proc( HDC_16(hdc), DCHC_DELETEDC, data, 0 )) return FALSE;
if (!(dc = DC_GetDCPtr( hdc ))) return TRUE; /* deleted by the hook */
}
}
while (dc->saveLevel)
{
DC * dcs;
- HDC16 hdcs = dc->header.hNext;
+ HDC hdcs = HDC_32(dc->header.hNext);
if (!(dcs = DC_GetDCPtr( hdcs ))) break;
dc->header.hNext = dcs->header.hNext;
dc->saveLevel--;
/***********************************************************************
* SetDCOrg (GDI.117)
*/
-DWORD WINAPI SetDCOrg16( HDC16 hdc, INT16 x, INT16 y )
+DWORD WINAPI SetDCOrg16( HDC16 hdc16, INT16 x, INT16 y )
{
DWORD prevOrg = 0;
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCPtr( hdc );
if (!dc) return 0;
if (dc->funcs->pSetDCOrg) prevOrg = dc->funcs->pSetDCOrg( dc->physDev, x, y );
/* relay function to call the 16-bit DC hook proc */
-static BOOL16 WINAPI call_dc_hook16( HDC16 hdc, WORD code, DWORD data, LPARAM lParam )
+static BOOL16 WINAPI call_dc_hook16( HDC16 hdc16, WORD code, DWORD data, LPARAM lParam )
{
FARPROC16 proc = NULL;
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
proc = dc->hookProc;
GDI_ReleaseObj( hdc );
if (!proc) return FALSE;
- return GDI_CallTo16_word_wwll( proc, hdc, code, data, lParam );
+ return GDI_CallTo16_word_wwll( proc, hdc16, code, data, lParam );
}
/***********************************************************************
* SetDCHook (GDI.190)
*/
-BOOL16 WINAPI SetDCHook16( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData )
+BOOL16 WINAPI SetDCHook16( HDC16 hdc16, FARPROC16 hookProc, DWORD dwHookData )
{
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCPtr( hdc );
if (!dc) return FALSE;
/***********************************************************************
* GetDCHook (GDI.191)
*/
-DWORD WINAPI GetDCHook16( HDC16 hdc, FARPROC16 *phookProc )
+DWORD WINAPI GetDCHook16( HDC16 hdc16, FARPROC16 *phookProc )
{
+ HDC hdc = HDC_32( hdc16 );
DC *dc = DC_GetDCPtr( hdc );
+ DWORD ret;
+
if (!dc) return 0;
*phookProc = dc->hookProc;
+ ret = dc->dwHookData;
GDI_ReleaseObj( hdc );
- return dc->dwHookData;
+ return ret;
}
/***********************************************************************
* SetHookFlags (GDI.192)
*/
-WORD WINAPI SetHookFlags16(HDC16 hDC, WORD flags)
+WORD WINAPI SetHookFlags16(HDC16 hdc16, WORD flags)
{
- DC *dc = DC_GetDCPtr( hDC );
+ HDC hdc = HDC_32( hdc16 );
+ DC *dc = DC_GetDCPtr( hdc );
if( dc )
{
/* "Undocumented Windows" info is slightly confusing.
*/
- TRACE("hDC %04x, flags %04x\n",hDC,flags);
+ TRACE("hDC %04x, flags %04x\n",hdc,flags);
if( flags & DCHF_INVALIDATEVISRGN )
dc->flags |= DC_DIRTY;
else if( flags & DCHF_VALIDATEVISRGN || !flags )
dc->flags &= ~DC_DIRTY;
- GDI_ReleaseObj( hDC );
+ GDI_ReleaseObj( hdc );
return wRet;
}
return 0;
WINE_DEFAULT_DEBUG_CHANNEL(gdi);
+#define HGDIOBJ_32(h16) ((HGDIOBJ)(ULONG_PTR)(h16))
/***********************************************************************
* GDI stock objects
if ((UINT_PTR)handle & 2) /* GDI heap handle */
{
- LOCAL_Unlock( GDI_HeapSel, handle );
- if ((new_handle = LOCAL_ReAlloc( GDI_HeapSel, handle, size, LMEM_MOVEABLE )))
+ HLOCAL16 h = LOWORD(handle);
+ LOCAL_Unlock( GDI_HeapSel, h );
+ if ((new_handle = (HGDIOBJ)(ULONG_PTR)LOCAL_ReAlloc( GDI_HeapSel, h, size, LMEM_MOVEABLE )))
{
assert( new_handle == handle ); /* moveable handle cannot change */
- return LOCAL_Lock( GDI_HeapSel, handle );
+ return LOCAL_Lock( GDI_HeapSel, h );
}
}
else
object->funcs = NULL;
if ((UINT_PTR)handle & 2) /* GDI heap handle */
{
- LOCAL_Unlock( GDI_HeapSel, handle );
- LOCAL_Free( GDI_HeapSel, handle );
+ HLOCAL16 h = LOWORD(handle);
+ LOCAL_Unlock( GDI_HeapSel, h );
+ LOCAL_Free( GDI_HeapSel, h );
}
else /* large heap handle */
{
if ((UINT_PTR)handle & 2) /* GDI heap handle */
{
- ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, handle );
+ HLOCAL16 h = LOWORD(handle);
+ ptr = (GDIOBJHDR *)LOCAL_Lock( GDI_HeapSel, h );
if (ptr)
{
if (((magic != MAGIC_DONTCARE) && (GDIMAGIC(ptr->wMagic) != magic)) ||
(GDIMAGIC(ptr->wMagic) < FIRST_MAGIC) ||
(GDIMAGIC(ptr->wMagic) > LAST_MAGIC))
{
- LOCAL_Unlock( GDI_HeapSel, handle );
+ LOCAL_Unlock( GDI_HeapSel, h );
ptr = NULL;
}
}
*/
void GDI_ReleaseObj( HGDIOBJ handle )
{
- if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, handle );
+ if ((UINT_PTR)handle & 2) LOCAL_Unlock( GDI_HeapSel, LOWORD(handle) );
TRACE_SEC( handle, "leave" );
_LeaveSysLevel( &GDI_level );
}
/***********************************************************************
* GetObject (GDI.82)
*/
-INT16 WINAPI GetObject16( HANDLE16 handle, INT16 count, LPVOID buffer )
+INT16 WINAPI GetObject16( HANDLE16 handle16, INT16 count, LPVOID buffer )
{
GDIOBJHDR * ptr;
+ HGDIOBJ handle = HGDIOBJ_32( handle16 );
INT16 result = 0;
+
TRACE("%04x %d %p\n", handle, count, buffer );
if (!count) return 0;
*
* returns type of object if valid (W95 system programming secrets p. 264-5)
*/
-BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle )
+BOOL16 WINAPI IsGDIObject16( HGDIOBJ16 handle16 )
{
UINT16 magic = 0;
+ HGDIOBJ handle = HGDIOBJ_32( handle16 );
GDIOBJHDR *object = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
if (object)
* with 0x2000 (OBJECT_PRIVATE), so we just do it.
* But Wine doesn't react on that yet.
*/
-void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle, BOOL16 private )
+void WINAPI MakeObjectPrivate16( HGDIOBJ16 handle16, BOOL16 private )
{
+ HGDIOBJ handle = HGDIOBJ_32( handle16 );
GDIOBJHDR *ptr = GDI_GetObjPtr( handle, MAGIC_DONTCARE );
if (!ptr)
{
/* free objects in handle table */
for(i = 0; i < mh->mtNoObjects; i++)
if(*(ht->objectHandle + i) != 0)
- DeleteObject(*(ht->objectHandle + i));
+ DeleteObject( (HGDIOBJ)(ULONG_PTR)(*(ht->objectHandle + i) ));
/* free handle table */
GlobalFree16(hHT);