
Help needed with GetGlyphOutline
Hi,
Using VisualBasic (3.0, but 4.0 16bits will do as well), I'd like
to use the API GetGlyphOutline.
But anytime this API is called (see source below), all kind
of strange things start to happen, ranging from some garbled
windowframes to complete shut-down of my Win3.11...
Your help is greatly appreciated.
My source code (form not included):
===
Type FIXED
fract As Integer
value As Integer
End Type
Type POINTAPI
x As Integer
y As Integer
End Type
Type GLYPHMETRICS
gmBlackBoxX As Integer
gmBlackBoxY As Integer
gmptGlyphOrigin As POINTAPI
gmCellIncX As Integer
gmCellIncY As Integer
End Type
Type MAT2
eM11 As FIXED
eM12 As FIXED
eM21 As FIXED
eM22 As FIXED
End Type
Global Const GGO_METRICS = 0
Global Const GGO_BITMAP = 1
Global Const GGO_NATIVE = 2
Public Const sNull As String = 0&
Private Declare Function GetGlyphOutline& Lib "GDI" _
(ByVal hdc%, ByVal uChar%, ByVal fuFormat%, lpgm As GLYPHMETRICS, _
ByVal cbBuffer&, ByVal lpBuffer$, lpmat2 As MAT2)
Private Sub Button_Click()
'
Dim lpgm As GLYPHMETRICS
Dim lpmat2 As MAT2
Dim Nr As Integer, lpBuffer$, cBuff&, r&, i&
'
Nr = CValue 'Some value representing an ASCII code, like 'i'=105
Label1.Caption = Nr
'
lpgm.gmBlackBoxX = 64
lpgm.gmBlackBoxY = 64
lpgm.gmptGlyphOrigin.x = 10
lpgm.gmptGlyphOrigin.y = 10
lpgm.gmCellIncX = 70
lpgm.gmCellIncY = 70
'
lpmat2.eM11.value = 1: lpmat2.eM11.fract = 0
lpmat2.eM12.value = 0: lpmat2.eM12.fract = 0
lpmat2.eM21.value = 0: lpmat2.eM21.fract = 0
lpmat2.eM22.value = 1: lpmat2.eM22.fract = 0
'
lpBuffer$ = String$(256, 0)
'
cBuff& = 0 'First retrieve number of bytes
r& = GetGlyphOutline(Picture1.hdc, Nr, GGO_NATIVE, lpgm, _
cBuff&, sNull, lpmat2)
If r& = -1 Then Beep: Exit Sub
'
lpBuffer$ = String$(r&, 0) 'Then retrieve the information
r& = GetGlyphOutline(Picture1.hdc, Nr, GGO_NATIVE, lpgm, _
Len(lpBuffer$), lpBuffer$, lpmat2)
If r& = -1 Then Beep: Exit Sub
'
lpBuffer$ = Left$(lpBuffer$, r&)
'
r& = InStr(lpBuffer$, Chr$(0))
If r& = 0 Then r& = Len(lpBuffer$)
If r& > 100 Then r& = 100
'
For i& = 1 To r&
Picture1.Print Asc(Mid$(lpBuffer$, i, 1)),
Next i
'
End Sub
===
Kind regards cq. De groeten,
Steven
--
A world that's far away,
where life is not unkind,
the movie in my mind...