GetDialogBaseUnits only returns the base units for the system font, which is bigger than the default GUI font. To return base units for any font, use this version of GetDialogBaseUnits that I created:
Code:
// hDC - DC of desired window
// hFont - handleof desired font
DWORD GetDialogBaseUnitsEx( HDC hDC, HFONT hFont ){
HFONT hFontPrev = NULL;
char *alphabet = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
SIZE sz,psz;
TEXTMETRIC tm;
if(!hDC) return FALSE;
if(hFont) hFontPrev = SelectFont(hDC, hFont);
if(!GetTextMetricsA(hDC, &tm)) return FALSE;
if(!GetTextExtentPointA(hDC, alphabet, 52, &sz)) return FALSE;
psz.cy = tm.tmHeight;
psz.cx = (sz.cx / 26 + 1) / 2;
if (hFontPrev) SelectFont(hDC, hFontPrev);
return MAKELONG(psz.cx,psz.cy);
}
// helper macros to convert dialog units to pixel units
// DlgSizeX(DlgWidth,BaseUnits)
// DlgSizeY(DlgHeight,BaseUnits)
#define DlgSizeX(x,db) MulDiv((x),LOWORD(db),4)
#define DlgSizeY(x,db) MulDiv((x),HIWORD(db),8)