gdi32: Store foreground/background color even when passed CLR_INVALID.

This commit is contained in:
Alexandre Julliard 2012-01-12 15:51:54 +01:00
parent 9ecc1e0702
commit f8fa169da0
2 changed files with 40 additions and 12 deletions

View File

@ -853,12 +853,8 @@ COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
if (dc) if (dc)
{ {
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor ); PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetBkColor );
color = physdev->funcs->pSetBkColor( physdev, color ); ret = dc->backgroundColor;
if (color != CLR_INVALID) dc->backgroundColor = physdev->funcs->pSetBkColor( physdev, color );
{
ret = dc->backgroundColor;
dc->backgroundColor = color;
}
release_dc_ptr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;
@ -894,12 +890,8 @@ COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
if (dc) if (dc)
{ {
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextColor ); PHYSDEV physdev = GET_DC_PHYSDEV( dc, pSetTextColor );
color = physdev->funcs->pSetTextColor( physdev, color ); ret = dc->textColor;
if (color != CLR_INVALID) dc->textColor = physdev->funcs->pSetTextColor( physdev, color );
{
ret = dc->textColor;
dc->textColor = color;
}
release_dc_ptr( dc ); release_dc_ptr( dc );
} }
return ret; return ret;

View File

@ -54,6 +54,41 @@ static void dump_region(HRGN hrgn)
HeapFree( GetProcessHeap(), 0, data ); HeapFree( GetProcessHeap(), 0, data );
} }
static void test_dc_values(void)
{
HDC hdc = CreateDCA("DISPLAY", NULL, NULL, NULL);
COLORREF color;
ok( hdc != NULL, "CreateDC failed\n" );
color = SetBkColor( hdc, 0x12345678 );
ok( color == 0xffffff, "initial color %08x\n", color );
color = GetBkColor( hdc );
ok( color == 0x12345678, "wrong color %08x\n", color );
color = SetBkColor( hdc, 0xffffffff );
ok( color == 0x12345678, "wrong color %08x\n", color );
color = GetBkColor( hdc );
ok( color == 0xffffffff, "wrong color %08x\n", color );
color = SetBkColor( hdc, 0 );
ok( color == 0xffffffff, "wrong color %08x\n", color );
color = GetBkColor( hdc );
ok( color == 0, "wrong color %08x\n", color );
color = SetTextColor( hdc, 0xffeeddcc );
ok( color == 0, "initial color %08x\n", color );
color = GetTextColor( hdc );
ok( color == 0xffeeddcc, "wrong color %08x\n", color );
color = SetTextColor( hdc, 0xffffffff );
ok( color == 0xffeeddcc, "wrong color %08x\n", color );
color = GetTextColor( hdc );
ok( color == 0xffffffff, "wrong color %08x\n", color );
color = SetTextColor( hdc, 0 );
ok( color == 0xffffffff, "wrong color %08x\n", color );
color = GetTextColor( hdc );
ok( color == 0, "wrong color %08x\n", color );
DeleteDC( hdc );
}
static void test_savedc_2(void) static void test_savedc_2(void)
{ {
HWND hwnd; HWND hwnd;
@ -999,6 +1034,7 @@ static void test_printer_dc(void)
START_TEST(dc) START_TEST(dc)
{ {
pSetLayout = (void *)GetProcAddress( GetModuleHandle("gdi32.dll"), "SetLayout"); pSetLayout = (void *)GetProcAddress( GetModuleHandle("gdi32.dll"), "SetLayout");
test_dc_values();
test_savedc(); test_savedc();
test_savedc_2(); test_savedc_2();
test_GdiConvertToDevmodeW(); test_GdiConvertToDevmodeW();