- hDC = CreateCompatibleDC(0);
- SelectObject(hDC, hFont);
+ hDCWnd = NULL;
+ hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE);
+ if (!hDC)
+ {
+ /* Retry with the DC of the owner window */
+ hDCWnd = lpMsgBoxParams->hwndOwner;
+ hDC = GetDCEx(hDCWnd, NULL, DCX_WINDOW | DCX_CACHE);
+ }
+ if (!hDC)
+ {
+ ERR("GetDCEx() failed, bail out!\n");
+ goto Quit;
+ }
+ hOldFont = SelectObject(hDC, hFont);
+
+ units.cx = GdiGetCharDimensions(hDC, NULL, &units.cy);
+ if (!units.cx)
+ {
+ DWORD defUnits;
+ ERR("GdiGetCharDimensions() failed, falling back to default values!\n");
+ defUnits = GetDialogBaseUnits();
+ units.cx = LOWORD(defUnits);
+ units.cy = HIWORD(defUnits);
+ }