Hi All,
Actually i am trying to send the form name to this procedure, but i am geting error saying Type mismatch.

Public Function GetFontDialogUnits() As Long

Dim hFont As Long
Dim hFontOld As Long
Dim r As Long
Dim avgWidth As Long
Dim hDc As Long
Dim tmp As String
Dim sz As SIZE

'get the hdc to the main window
hDc = GetDC(Form1.hwnd)

'with the current font attributes, select the font
hFont = GetStockObject(ANSI_VAR_FONT)
hFontOld = SelectObject(hDc, hFont&)

'get its length, then calculate the average character width
tmp = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
GetTextExtentPoint32(hDc, tmp, 52, sz)
avgWidth = (sz.cx \ 52)

're-select the previous font & delete the hDc
SelectObject(hDc, hFontOld)
DeleteObject(hFont)
ReleaseDC(Form1.hwnd, hDc)

'return the average character width
GetFontDialogUnits = avgWidth

End Function


Please help is needed.

Mahesh