From 3e86d43030e36ce85b330620be3cca638542906a Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sat, 30 Oct 2010 13:35:43 -0500 Subject: [PATCH] gdiplus: Don't rely on an HDC in GdipMeasureString. --- dlls/gdiplus/graphics.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index da2d9663d2a..5ec54adf1ec 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -3918,6 +3918,7 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, { HFONT oldfont; struct measure_string_args args; + HDC temp_hdc=NULL; TRACE("(%p, %s, %i, %p, %s, %p, %p, %p, %p)\n", graphics, debugstr_wn(string, length), length, font, debugstr_rectf(rect), format, @@ -3928,8 +3929,8 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, if(!graphics->hdc) { - FIXME("graphics object has no HDC\n"); - return NotImplemented; + temp_hdc = graphics->hdc = CreateCompatibleDC(0); + if (!temp_hdc) return OutOfMemory; } if(linesfilled) *linesfilled = 0; @@ -3954,6 +3955,12 @@ GpStatus WINGDIPAPI GdipMeasureString(GpGraphics *graphics, DeleteObject(SelectObject(graphics->hdc, oldfont)); + if (temp_hdc) + { + graphics->hdc = NULL; + DeleteDC(temp_hdc); + } + return Ok; }