怎么在ActiveX DLL的内存DC中设定字体,并且得到字符的宽和高

如何在ActiveX DLL的内存DC中设定字体,并且得到字符的宽和高?
我需要用ActiveX   DLL画图,写字,在asp中调用。

现在已经研究明白怎么建立内存DC,怎么输出图像。但是,写字需要知道一个英文字符在某个字体时的高度和宽度。

实在没有找到相关资料,只能在   ActiveX   DLL   中加了一个Form,设定为不显示,然后用以前的办法。
奇迹出现了,在asp中居然真的能取得字体的宽和高。

我是这么做的:
**********************************
        Private   tmpCharWidth,   tmpCharHeight   As   Long         '属性的临时变量

Public   Sub   mGetFontSize()
        Dim   myFont   As   StdFont
        Set   myFont   =   New   StdFont
       
        With   myFont
                .Name   =   "黑体 "
                .Bold   =   True
                .Italic   =   True
                .Size   =   35
        End   With

        Set   Form1.Picture1.Font   =   myFont

        tmpCharWidth   =   Form1.Picture1.TextWidth( "Q ")
        tmpCharHeight   =   Form1.Picture1.TextHeight( "Q ")

Debug.Print   "tmpCharWidth,tmpCharHeight "   &   tmpCharWidth,   tmpCharHeight
       
        Set   myFont   =   Nothing
End   Sub

Public   Property   Get   pCharWidth()   As   Long
        pCharWidth   =   tmpCharWidth
End   Property

Public   Property   Get   pCharHeight()   As   Long
        pCharHeight   =   tmpCharHeight
End   Property
**********************************

可是这样做显然不符合DLL的规范。
那位知道怎么在内存DC中设定字体,并且得到一个字符串以这个字体输出时得到的宽高?


------解决方案--------------------
CreateFontIndirect

代码你用google搜吧
------解决方案--------------------
这是我从我的cimage类中截取的部分代码,我用的就是内存DC
'*********************************** 图形处理的方法 ******************************

Public Function SetFont(Font As StdFont, Optional ByVal Angle = 0) As Long
If Me.hdc = 0 Then Exit Function
Dim tlFont As LOGFONT
With tlFont
.lfHeight = (-20 * Font.Size) / Screen.TwipsPerPixelY
.lfWidth = 0
.lfEscapement = Angle * 10
If Font.Bold Then
.lfWeight = 700
Else
.lfWeight = 400
End If
.lfItalic = Font.Italic
.lfUnderline = Font.Underline
.lfStrikeOut = Font.Strikethrough
.lfCharSet = Font.Charset
CopyMemory .lfFaceName(1), Font.Name, LenB(StrConv(Font.Name, vbFromUnicode)) + 1
End With
If mhFont <> 0 Then
SelectObject Me.hdc, mhOldFont
DeleteObject mhFont
End If
mhFont = CreateFontIndirect(tlFont)
mhOldFont = SelectObject(Me.hdc, mhFont)
SetFont = mhOldFont
End Function

Public Property Get TextWidth(ByVal Str As String) As Long
Dim lpSize As Size
GetTextExtentPoint32 Me.hdc, Str, LenB(StrConv(Str, vbFromUnicode)), lpSize
TextWidth = lpSize.cx
End Property

Public Property Get TextHeight(ByVal Str As String) As Long