Private Sub SetFont(ByVal objFont As Font)
Dim lngHDC As Long
Dim lngFont As Long
Dim lngInd1 As Long
Dim typLogFont As LOGFONT
lngHDC = GetDC(lngHandle)
For lngInd1 = 1 To Len(objFont.Name)
typLogFont.lfFaceName(lngInd1) = Asc(Mid$(objFont.Name, lngInd1, 1))
Next lngInd1
' typLogFont.lfFaceName = StrConv(objFont.Name, vbFromUnicode)
typLogFont.lfWeight = objFont.Weight
typLogFont.lfItalic = objFont.Italic
typLogFont.lfUnderline = objFont.Underline
typLogFont.lfStrikeOut = objFont.Strikethrough
typLogFont.lfCharSet = objFont.Charset
lngFont = CreateFontIndirect(typLogFont)
lngReturnValue = SelectObject(lngHDC, lngFont)
lngReturnValue = DeleteObject(lngFont)
lngReturnValue = ReleaseDC(lngHandle, lngHDC)
End Sub
Thank U in advance, Marco
You've posted some code, here, from which I infer that you are primarily a C
programmer. But you've left out the one critical bit: lngHandle must have
larger scope than we see here, and we have no idea where it is assigned.
Just put the right window handle into it and it should work fine. Creating
your own windows in VB is somewhat fraught, but whatever floats your boat...
Jim Deutch
MS Dev MVP
Marco Filippini wrote in message
<#UnV9RxG$GA....@cppssbbsa02.microsoft.com>...