diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c index 0f1daa2125b..cba97c1231a 100644 --- a/dlls/gdi32/dc.c +++ b/dlls/gdi32/dc.c @@ -1555,34 +1555,6 @@ INT WINAPI GetRelAbs( HDC hdc, DWORD dwIgnore ) } -/*********************************************************************** - * SetBkMode (GDI32.@) - */ -INT WINAPI SetBkMode( HDC hdc, INT mode ) -{ - INT ret = 0; - DC *dc; - - if ((mode <= 0) || (mode > BKMODE_LAST)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - if ((dc = get_dc_ptr( hdc ))) - { - PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkMode ); - mode = physdev->funcs->pSetBkMode( physdev, mode ); - if (mode) - { - ret = dc->attr->background_mode; - dc->attr->background_mode = mode; - } - release_dc_ptr( dc ); - } - return ret; -} - - /*********************************************************************** * GetROP2 (GDI32.@) */ diff --git a/dlls/gdi32/enhmfdrv/dc.c b/dlls/gdi32/enhmfdrv/dc.c index 2c639e9dde3..c0a53045099 100644 --- a/dlls/gdi32/enhmfdrv/dc.c +++ b/dlls/gdi32/enhmfdrv/dc.c @@ -80,13 +80,13 @@ BOOL CDECL EMFDRV_SetTextJustification(PHYSDEV dev, INT nBreakExtra, INT nBreakC return EMFDRV_WriteRecord(dev, &emr.emr); } -INT CDECL EMFDRV_SetBkMode( PHYSDEV dev, INT mode ) +BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode ) { EMRSETBKMODE emr; emr.emr.iType = EMR_SETBKMODE; emr.emr.nSize = sizeof(emr); emr.iMode = mode; - return EMFDRV_WriteRecord( dev, &emr.emr ) ? mode : 0; + return EMFDRV_WriteRecord( dc_attr->emf, &emr.emr ); } COLORREF CDECL EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) diff --git a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h index e21ff90a119..b80e0ffafd2 100644 --- a/dlls/gdi32/enhmfdrv/enhmetafiledrv.h +++ b/dlls/gdi32/enhmfdrv/enhmetafiledrv.h @@ -115,7 +115,6 @@ extern HPEN CDECL EMFDRV_SelectPen( PHYSDEV dev, HPEN handle, const struct b extern HPALETTE CDECL EMFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPal, BOOL force ) DECLSPEC_HIDDEN; extern INT CDECL EMFDRV_SetArcDirection( PHYSDEV dev, INT arcDirection ) DECLSPEC_HIDDEN; extern COLORREF CDECL EMFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; -extern INT CDECL EMFDRV_SetBkMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN; extern COLORREF CDECL EMFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF CDECL EMFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern INT CDECL EMFDRV_SetDIBitsToDevice( PHYSDEV dev, INT xDest, INT yDest, DWORD cx, DWORD cy, INT xSrc, diff --git a/dlls/gdi32/enhmfdrv/init.c b/dlls/gdi32/enhmfdrv/init.c index f4bfc20b687..27856434d50 100644 --- a/dlls/gdi32/enhmfdrv/init.c +++ b/dlls/gdi32/enhmfdrv/init.c @@ -129,7 +129,7 @@ static const struct gdi_dc_funcs emfdrv_driver = EMFDRV_SelectPen, /* pSelectPen */ EMFDRV_SetArcDirection, /* pSetArcDirection */ EMFDRV_SetBkColor, /* pSetBkColor */ - EMFDRV_SetBkMode, /* pSetBkMode */ + NULL, /* pSetBkMode */ NULL, /* pSetBoundsRect */ EMFDRV_SetDCBrushColor, /* pSetDCBrushColor*/ EMFDRV_SetDCPenColor, /* pSetDCPenColor*/ diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h index bfc25ab5da1..37cec4bfe78 100644 --- a/dlls/gdi32/gdi_private.h +++ b/dlls/gdi32/gdi_private.h @@ -66,6 +66,7 @@ extern BOOL METADC_Polyline( HDC hdc, const POINT *points,INT count) DECLSPEC_HI extern BOOL METADC_Rectangle( HDC hdc, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN; extern BOOL METADC_RoundRect( HDC hdc, INT left, INT top, INT right, INT bottom, INT ell_width, INT ell_height ) DECLSPEC_HIDDEN; +extern BOOL METADC_SetBkMode( HDC hdc, INT mode ) DECLSPEC_HIDDEN; extern BOOL METADC_SetPixel( HDC hdc, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN; extern BOOL METADC_SetTextAlign( HDC hdc, UINT align ) DECLSPEC_HIDDEN; @@ -109,6 +110,7 @@ extern BOOL EMFDC_Rectangle( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom) DECLSPEC_HIDDEN; extern BOOL EMFDC_RoundRect( DC_ATTR *dc_attr, INT left, INT top, INT right, INT bottom, INT ell_width, INT ell_height ) DECLSPEC_HIDDEN; +extern BOOL EMFDC_SetBkMode( DC_ATTR *dc_attr, INT mode ) DECLSPEC_HIDDEN; extern BOOL EMFDC_SetPixel( DC_ATTR *dc_attr, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN; extern BOOL EMFDC_SetTextAlign( DC_ATTR *dc_attr, UINT align ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/gdidc.c b/dlls/gdi32/gdidc.c index b6ae60b45fd..3b477f920f9 100644 --- a/dlls/gdi32/gdidc.c +++ b/dlls/gdi32/gdidc.c @@ -74,6 +74,29 @@ INT WINAPI GetBkMode( HDC hdc ) return dc_attr ? dc_attr->background_mode : 0; } +/*********************************************************************** + * SetBkMode (GDI32.@) + */ +INT WINAPI SetBkMode( HDC hdc, INT mode ) +{ + DC_ATTR *dc_attr; + INT ret; + + if (mode <= 0 || mode > BKMODE_LAST) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + if (is_meta_dc( hdc )) return METADC_SetBkMode( hdc, mode ); + if (!(dc_attr = get_dc_attr( hdc ))) return 0; + if (dc_attr->emf && !EMFDC_SetBkMode( dc_attr, mode )) return 0; + + ret = dc_attr->background_mode; + dc_attr->background_mode = mode; + return ret; +} + /*********************************************************************** * GetCurrentPositionEx (GDI32.@) */ diff --git a/dlls/gdi32/mfdrv/dc.c b/dlls/gdi32/mfdrv/dc.c index a3664365f9c..0ebb9b660e7 100644 --- a/dlls/gdi32/mfdrv/dc.c +++ b/dlls/gdi32/mfdrv/dc.c @@ -35,9 +35,9 @@ BOOL METADC_SetTextAlign( HDC hdc, UINT align ) return metadc_param2( hdc, META_SETTEXTALIGN, HIWORD(align), LOWORD(align) ); } -INT CDECL MFDRV_SetBkMode( PHYSDEV dev, INT mode ) +BOOL METADC_SetBkMode( HDC hdc, INT mode ) { - return MFDRV_MetaParam1( dev, META_SETBKMODE, (WORD)mode) ? mode : 0; + return metadc_param1( hdc, META_SETBKMODE, (WORD)mode ); } COLORREF CDECL MFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) diff --git a/dlls/gdi32/mfdrv/init.c b/dlls/gdi32/mfdrv/init.c index 7c69ca5d106..3733d93e554 100644 --- a/dlls/gdi32/mfdrv/init.c +++ b/dlls/gdi32/mfdrv/init.c @@ -192,7 +192,7 @@ static const struct gdi_dc_funcs MFDRV_Funcs = MFDRV_SelectPen, /* pSelectPen */ NULL, /* pSetArcDirection */ MFDRV_SetBkColor, /* pSetBkColor */ - MFDRV_SetBkMode, /* pSetBkMode */ + NULL, /* pSetBkMode */ MFDRV_SetBoundsRect, /* pSetBoundsRect */ MFDRV_SetDCBrushColor, /* pSetDCBrushColor*/ MFDRV_SetDCPenColor, /* pSetDCPenColor*/ @@ -612,6 +612,14 @@ BOOL metadc_record( HDC hdc, METARECORD *mr, DWORD rlen ) return MFDRV_WriteRecord( &dev->dev, mr, rlen ); } +BOOL metadc_param1( HDC hdc, short func, short param ) +{ + METAFILEDRV_PDEVICE *dev; + + if (!(dev = get_metadc_ptr( hdc ))) return FALSE; + return MFDRV_MetaParam1( &dev->dev, func, param ); +} + BOOL metadc_param2( HDC hdc, short func, short param1, short param2 ) { METAFILEDRV_PDEVICE *dev; diff --git a/dlls/gdi32/mfdrv/metafiledrv.h b/dlls/gdi32/mfdrv/metafiledrv.h index 9e1ca0fedc1..5a9997209e7 100644 --- a/dlls/gdi32/mfdrv/metafiledrv.h +++ b/dlls/gdi32/mfdrv/metafiledrv.h @@ -60,6 +60,7 @@ extern BOOL MFDRV_RemoveHandle( PHYSDEV dev, UINT index ) DECLSPEC_HIDDEN; extern INT16 MFDRV_CreateBrushIndirect( PHYSDEV dev, HBRUSH hBrush ) DECLSPEC_HIDDEN; extern METAFILEDRV_PDEVICE *get_metadc_ptr( HDC hdc ) DECLSPEC_HIDDEN; +extern BOOL metadc_param1( HDC hdc, short func, short param ) DECLSPEC_HIDDEN; extern BOOL metadc_param2( HDC hdc, short func, short param1, short param2 ) DECLSPEC_HIDDEN; extern BOOL metadc_param4( HDC hdc, short func, short param1, short param2, short param3, short param4 ) DECLSPEC_HIDDEN; @@ -105,7 +106,6 @@ extern HPEN CDECL MFDRV_SelectPen( PHYSDEV dev, HPEN handle, const struct brush extern HPALETTE CDECL MFDRV_SelectPalette( PHYSDEV dev, HPALETTE hPalette, BOOL bForceBackground) DECLSPEC_HIDDEN; extern UINT CDECL MFDRV_RealizePalette(PHYSDEV dev, HPALETTE hPalette, BOOL primary) DECLSPEC_HIDDEN; extern COLORREF CDECL MFDRV_SetBkColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; -extern INT CDECL MFDRV_SetBkMode( PHYSDEV dev, INT mode ) DECLSPEC_HIDDEN; extern COLORREF CDECL MFDRV_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF CDECL MFDRV_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern DWORD CDECL MFDRV_SetLayout( PHYSDEV dev, DWORD layout ) DECLSPEC_HIDDEN; diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c index 8aa3b201b8b..3d5da4acb74 100644 --- a/dlls/gdi32/tests/dc.c +++ b/dlls/gdi32/tests/dc.c @@ -40,7 +40,7 @@ static void test_dc_values(void) { HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL); COLORREF color; - int extra; + int extra, attr; ok( hdc != NULL, "CreateDC failed\n" ); color = SetBkColor( hdc, 0x12345678 ); @@ -81,6 +81,11 @@ static void test_dc_values(void) extra = GetTextCharacterExtra( hdc ); ok( extra == 123, "initial extra %d\n", extra ); + SetLastError(0xdeadbeef); + attr = SetBkMode(ULongToHandle(0xdeadbeef), OPAQUE); + ok(!attr, "attr = %x\n", attr); + ok(GetLastError() == ERROR_INVALID_HANDLE, "GetLastError() = %u\n", GetLastError()); + DeleteDC( hdc ); } diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c index fdef4049243..8a492a336fb 100644 --- a/dlls/gdi32/tests/metafile.c +++ b/dlls/gdi32/tests/metafile.c @@ -3127,6 +3127,11 @@ static void test_mf_attrs(void) attr = SetTextAlign(hdc, TA_TOP); ok(attr == TRUE, "attr = %x\n", attr); + attr = SetBkMode(hdc, TRANSPARENT); + ok(attr == TRUE, "attr = %x\n", attr); + attr = SetBkMode(hdc, OPAQUE); + ok(attr == TRUE, "attr = %x\n", attr); + mf = CloseMetaFile(hdc); ok(mf != 0, "CloseEnhMetaFile failed\n"); DeleteMetaFile(mf); @@ -3280,6 +3285,11 @@ static void test_emf_attrs(void) attr = SetTextAlign(hdc, TA_TOP); ok(attr == TA_BOTTOM, "attr = %x\n", attr); + attr = SetBkMode(hdc, TRANSPARENT); + ok(attr == OPAQUE, "attr = %x\n", attr); + attr = SetBkMode(hdc, OPAQUE); + ok(attr == TRANSPARENT, "attr = %x\n", attr); + mf = CloseEnhMetaFile(hdc); ok(mf != 0, "CloseEnhMetaFile failed\n"); DeleteEnhMetaFile(mf);