Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Win API / March 2006



Tip: Looking for answers? Try searching our database.

How to use GetFontUnicodeRanges() in VB or VBA?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary - 23 Mar 2006 21:49 GMT
Hi, there,

Any one has the example code for using GetFontUnicodeRanges in VB or vba? Or
where I can find such information on website?

I don't know how to declare GLYPHSET. Although I put null in the function,
and hoped it returns the number of Unicode points supported, the application
crashed. To declare GLYPHSET, I need to declare WCRANGE also. An example is
highly appreciated!

Thanks lot in advance,
Thorsten Albers - 23 Mar 2006 23:57 GMT
Gary <Gary@discussions.microsoft.com> schrieb im Beitrag
<71AFA002-22B4-41BE-992C-19C06DEDAC22@microsoft.com>...
> Any one has the example code for using GetFontUnicodeRanges in VB or vba? Or
> where I can find such information on website?
> I don't know how to declare GLYPHSET. Although I put null in the function,
> and hoped it returns the number of Unicode points supported, the application
> crashed. To declare GLYPHSET, I need to declare WCRANGE also. An example is
> highly appreciated!

GLYPHSET is a structure with an array of WCRANGE structures (field
"ranges"). This means that the size of this structure is variable. On the
one hand it is not possible to get the count of items of the array without
getting the GLYPHSET structure, on the other hand it is not possible to get
the GLYPHSET structure without knowing its total size, i.e. the count of
items of the array.
Therefore the function GetFontUnicodeRanges() provides another way: Setting
the second parameter to NULL lets the function return the total size of the
GLYPHSET structure. This will not help you to get the full GLYPHSET
structure in VB directly, but by this you can retrieve it indirectly.
Sample code ('on the fly'):

Private Declare Function GetFontUnicodeRanges _
                        Lib "gdi32.dll" _
                        ( _
                          ByVal hDC As Long, _
                          pGLYPHSET As Any _
                        ) As Long

Private Declare Sub CopyMemory _
                   Lib "kernel32" Alias "RtlMoveMemory" _
                   ( _
                     pDestination As Any, _
                     pSource As Any, _
                     ByVal lByteCount As Long _
                   )

Private type typWCRANGE
 iLow As Integer
 iGlyphs As Integer
End Type

Private type typGLYPHSET
 lStructSize As Long
 lAccel As Long
 lGlyphsSupported As Long
 lRanges As Long
 aRANGE() As typWCRANGE
End Type

Dim abData() As Byte, lIndexData As Long
Dim lResult As Long, lCount As Long, lIndex As Long
Dim GS as

lResult& = GetFontUnicodeRanges(hDC, ByVal 0&)
If lResult& Then
 ReDim abData(0 To (lResult& - 1)) As Byte
 lResult& = GetFontUnicodeRanges(hDC, abData(LBound(abData)))
 If lResult& Then
   lIndexData& = LBound(abData)
   lCount& = 4& * 4&
   Call CopyMemory(GS, abData(lIndexData), lCount&)
   lIndexData& = lIndexData& + lCount&
   With GS
     If .lRanges& Then
       ReDim .aRANGE(0 To (.lRanges& - 1)) As typWCRANGE
       lIndex& = LBound(.aRANGE)
       lCount = .lRanges&
       While lCount&
         Call CopyMemory(.aRANGE(lIndex&), abData(lIndexData&),
Len(.aRANGE(lIndex&)))
         lIndexData& = lIndexData& + Len(.aRANGE(lIndex&))
         lIndex& = lIndex& + 1
         lCount& = lCount& - 1
       Wend
     End If
   End With
 End If
End If

Signature

----------------------------------------------------------------------
THORSTEN ALBERS                       Universität Freiburg
                                               albers@
                                                      uni-freiburg.de
----------------------------------------------------------------------

Gary - 27 Mar 2006 16:19 GMT
Thorsten,

Thanks lot for your help. It works perfectly. You solved a big issue for me

Sorry that I didn't see your original post before I replied to you.

Gary

> Gary <Gary@discussions.microsoft.com> schrieb im Beitrag
> <71AFA002-22B4-41BE-992C-19C06DEDAC22@microsoft.com>...
[quoted text clipped - 78 lines]
>   End If
> End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2012 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.