gdiplus: Don't rely on an HDC in GdipMeasureString.

This commit is contained in:
Vincent Povirk 2010-10-30 13:35:43 -05:00 committed by Alexandre Julliard
parent 867f3d39e7
commit 3e86d43030
1 changed files with 9 additions and 2 deletions

View File

@ -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;
}