--- a/ooDialog/trunk/ooDialog/ooDialog.cpp
+++ b/ooDialog/trunk/ooDialog/ooDialog.cpp
@@ -3658,55 +3658,23 @@
 {
     pCPlainBaseDialog pcpbd = (pCPlainBaseDialog)pCSelf;
 
-    HWND hDlg     = pcpbd->hDlg;
     SIZE textSize = {0};
 
-    // If hwnd is null, this will get a DC for the entire screen and that should be ok.
-    HDC hdc = GetDC(hDlg);
-    if ( hdc == NULL )
-    {
-        systemServiceExceptionCode(context->threadContext, API_FAILED_MSG, "GetDC");
-        goto error_out;
-    }
-
-    HFONT dlgFont = NULL;
-    bool createdFont = false;
-
-    if ( hDlg == NULL )
-    {
-        dlgFont = createFontFromName(hdc, pcpbd->fontName, pcpbd->fontSize);
-        if ( dlgFont != NULL )
-        {
-            createdFont = true;
+    if ( pcpbd->hDlg == NULL )
+    {
+        if ( ! getTextSizeDuInactiveDlg(context, pcpbd, text, &textSize) )
+        {
+            goto error_out;
         }
     }
     else
     {
-        dlgFont = (HFONT)SendMessage(hDlg, WM_GETFONT, 0, 0);
-    }
-
-    // If the font is still null we use the stock system font.  Even if we have
-    // the dialog handle, the font could be null if WM_SETFONT was not used.  In
-    // this case the stock system font will be correct.  If the
-    // createFontFromName() failed, well that is unlikely.  Just use the stock
-    // system font in that case.
-    if ( dlgFont == NULL )
-    {
-        dlgFont = (HFONT)GetStockObject(SYSTEM_FONT);
-    }
-
-    HFONT hOldFont = (HFONT)SelectObject(hdc, dlgFont);
-
-    GetTextExtentPoint32(hdc, text, (int)strlen(text), &textSize);
-    screenToDlgUnit(hdc, (POINT *)&textSize, 1);
-
-    SelectObject(hdc, hOldFont);
-    ReleaseDC(hDlg, hdc);
-
-    if ( createdFont )
-    {
-        DeleteObject(dlgFont);
-    }
+        if ( ! getTextSizeDuActiveDlg(context, pcpbd, text, &textSize) )
+        {
+            goto error_out;
+        }
+    }
+
     return rxNewSize(context, textSize.cx, textSize.cy);
 
 error_out: