From 118ce5dec18e858f6bc991b0b2aa8d49144738b2 Mon Sep 17 00:00:00 2001 From: Sheri Steeves Date: Tue, 18 Apr 2000 11:53:23 +0000 Subject: [PATCH] EMR_SELECTOBJECT records stock objects with their id as the object handle and the high bit set. --- graphics/enhmetafiledrv/objects.c | 58 ++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/graphics/enhmetafiledrv/objects.c b/graphics/enhmetafiledrv/objects.c index f373cebcf7c..0e0ccd9768d 100644 --- a/graphics/enhmetafiledrv/objects.c +++ b/graphics/enhmetafiledrv/objects.c @@ -104,10 +104,25 @@ static HBRUSH EMFDRV_BRUSH_SelectObject(DC *dc, HBRUSH hBrush ) EMRSELECTOBJECT emr; DWORD index; HBRUSH hOldBrush; - - index = EMFDRV_CreateBrushIndirect(dc, hBrush ); - if(!index) return FALSE; + /* If the object is a stock brush object, do not need to create it. + * See definitions in wingdi.h for range of stock brushes. + * We do however have to handle setting the higher order bit to + * designate that this is a stock object. + */ + if (hBrush >= FIRST_STOCK_HANDLE && + hBrush <= FIRST_STOCK_HANDLE+HOLLOW_BRUSH ) + { + DWORD brush_index = hBrush - FIRST_STOCK_HANDLE; + index = brush_index | 0x80000000; + } + else + { + index = EMFDRV_CreateBrushIndirect(dc, hBrush ); + } + + if(!index) return FALSE; + emr.emr.iType = EMR_SELECTOBJECT; emr.emr.nSize = sizeof(emr); emr.ihObject = index; @@ -169,7 +184,24 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont ) DWORD index; HFONT hOldFont; - index = EMFDRV_CreateFontIndirect(dc, hFont ); + /* If the object is a stock font object, do not need to create it. + * See definitions in wingdi.h for range of stock fonts. + * We do however have to handle setting the higher order bit to + * designate that this is a stock object. + */ + + if (hFont >= STOCK_OEM_FIXED_FONT && + hFont <= STOCK_DEFAULT_GUI_FONT && + hFont != STOCK_DEFAULT_PALETTE) + { + DWORD font_index = hFont - FIRST_STOCK_HANDLE; + index = font_index | 0x80000000; + } + else + { + index = EMFDRV_CreateFontIndirect(dc, hFont ); + } + if(!index) return FALSE; emr.emr.iType = EMR_SELECTOBJECT; @@ -214,7 +246,23 @@ static HPEN EMFDRV_PEN_SelectObject(DC *dc, HPEN hPen ) DWORD index; HFONT hOldPen; - index = EMFDRV_CreatePenIndirect(dc, hPen ); + /* If the object is a stock pen object, do not need to create it. + * See definitions in wingdi.h for range of stock pens. + * We do however have to handle setting the higher order bit to + * designate that this is a stock object. + */ + + if (hPen >= STOCK_WHITE_PEN && + hPen <= STOCK_NULL_PEN ) + { + DWORD pen_index = hPen - FIRST_STOCK_HANDLE; + index = pen_index | 0x80000000; + } + else + { + index = EMFDRV_CreatePenIndirect(dc, hPen ); + } + if(!index) return FALSE; emr.emr.iType = EMR_SELECTOBJECT;