From 299f25870a2afccb7f85e3416a48c0ed399efb05 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sat, 30 Oct 2010 13:35:43 -0500 Subject: [PATCH 5/6] gdiplus: Don't rely on an HDC in GdipMeasureString. --- dlls/gdiplus/graphics.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index da2d966..5ec54ad 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; } -- 1.7.1