gdi32: Don't allow CreateCompatibleDC on a metafile DC.
This commit is contained in:
parent
cef1832bfb
commit
c331a1a6cd
|
@ -30,6 +30,7 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(metafile);
|
||||
|
||||
static BOOL MFDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev );
|
||||
static BOOL MFDRV_DeleteDC( PHYSDEV dev );
|
||||
|
||||
|
||||
|
@ -91,7 +92,7 @@ static const DC_FUNCTIONS MFDRV_Funcs =
|
|||
MFDRV_Chord, /* pChord */
|
||||
MFDRV_CloseFigure, /* pCloseFigure */
|
||||
NULL, /* pCreateBitmap */
|
||||
NULL, /* pCreateCompatibleDC */
|
||||
MFDRV_CreateCompatibleDC, /* pCreateCompatibleDC */
|
||||
NULL, /* pCreateDC */
|
||||
NULL, /* pCreateDIBSection */
|
||||
NULL, /* pDeleteBitmap */
|
||||
|
@ -246,6 +247,16 @@ static DC *MFDRV_AllocMetaFile(void)
|
|||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* MFDRV_CreateCompatibleDC
|
||||
*/
|
||||
static BOOL MFDRV_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
|
||||
{
|
||||
/* not supported on metafile DCs */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* MFDRV_DeleteDC
|
||||
*/
|
||||
|
|
|
@ -265,20 +265,50 @@ static void test_GdiConvertToDevmodeW(void)
|
|||
static void test_CreateCompatibleDC(void)
|
||||
{
|
||||
BOOL bRet;
|
||||
HDC hDC;
|
||||
HDC hNewDC;
|
||||
HDC hdc, hNewDC, hdcMetafile;
|
||||
HBITMAP bitmap;
|
||||
INT caps;
|
||||
|
||||
bitmap = CreateBitmap( 10, 10, 1, 1, NULL );
|
||||
|
||||
/* Create a DC compatible with the screen */
|
||||
hDC = CreateCompatibleDC(NULL);
|
||||
ok(hDC != NULL, "CreateCompatibleDC returned %p\n", hDC);
|
||||
hdc = CreateCompatibleDC(NULL);
|
||||
ok(hdc != NULL, "CreateCompatibleDC returned %p\n", hdc);
|
||||
ok( SelectObject( hdc, bitmap ) != 0, "SelectObject failed\n" );
|
||||
caps = GetDeviceCaps( hdc, TECHNOLOGY );
|
||||
ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
|
||||
|
||||
/* Delete this DC, this should succeed */
|
||||
bRet = DeleteDC(hDC);
|
||||
bRet = DeleteDC(hdc);
|
||||
ok(bRet == TRUE, "DeleteDC returned %u\n", bRet);
|
||||
|
||||
/* Try to create a DC compatible to the deleted DC. This has to fail */
|
||||
hNewDC = CreateCompatibleDC(hDC);
|
||||
hNewDC = CreateCompatibleDC(hdc);
|
||||
ok(hNewDC == NULL, "CreateCompatibleDC returned %p\n", hNewDC);
|
||||
|
||||
hdc = GetDC( 0 );
|
||||
hdcMetafile = CreateEnhMetaFileA(hdc, NULL, NULL, NULL);
|
||||
ok(hdcMetafile != 0, "CreateEnhMetaFileA failed\n");
|
||||
hNewDC = CreateCompatibleDC( hdcMetafile );
|
||||
ok(hNewDC != NULL, "CreateCompatibleDC failed\n");
|
||||
ok( SelectObject( hNewDC, bitmap ) != 0, "SelectObject failed\n" );
|
||||
caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY );
|
||||
ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
|
||||
caps = GetDeviceCaps( hNewDC, TECHNOLOGY );
|
||||
ok( caps == DT_RASDISPLAY, "wrong caps %u\n", caps );
|
||||
DeleteDC( hNewDC );
|
||||
DeleteEnhMetaFile( CloseEnhMetaFile( hdcMetafile ));
|
||||
ReleaseDC( 0, hdc );
|
||||
|
||||
hdcMetafile = CreateMetaFileA(NULL);
|
||||
ok(hdcMetafile != 0, "CreateEnhMetaFileA failed\n");
|
||||
hNewDC = CreateCompatibleDC( hdcMetafile );
|
||||
ok(hNewDC == NULL, "CreateCompatibleDC succeeded\n");
|
||||
caps = GetDeviceCaps( hdcMetafile, TECHNOLOGY );
|
||||
ok( caps == DT_METAFILE, "wrong caps %u\n", caps );
|
||||
DeleteMetaFile( CloseMetaFile( hdcMetafile ));
|
||||
|
||||
DeleteObject( bitmap );
|
||||
}
|
||||
|
||||
static void test_DC_bitmap(void)
|
||||
|
|
Loading…
Reference in New Issue