S
Sylvain Audet
Hello!
We have a Windows application that is using Crystal Reports reports
containing Barcode fonts. Those reports are called through reflection into
a Crystal Report Viewer and we need to have the Barcode fonts to be
self-installed at runtime whenever a report is viewed.
I tried the following steps:
Public Shared Sub InstallFonts()
Dim fi As System.IO.FileInfo
Try
Dim res As Integer
fi = New System.IO.FileInfo(\\multi316\oasys\Reports\REQUIRED
FONTS\3of9.ttf)
Dim fiTarget As New System.IO.FileInfo("C:\Windows\Fonts\3OF9.TTF")
If fiTarget.Exists Then Return
' copy the font
fi.CopyTo("C:\Windows\Fonts\3OF9.TTF")
' add the font
res = CreateScalableFontResource(0, "c:\windows\Temp\3OF9.FOT",
"c:\windows\fonts\3OF9.TTF", String.Empty)
res = AddFontResource("C:\Windows\Temp\3OF9.FOT")
If res > 0 Then
' alert all windows that a font was added
SendMessage(New System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE, 0,
Nothing)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Everything looks to be ok as my .FOT file is created and both
AddFontResource and CreateScalableFontResource have a return value of 1
meaning the font was correctly added to the font collection.
The problem I am having is with the final part, the line below keep
executing forever:
SendMessage(New System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE, 0,
Nothing)
I also tried different version like :
SendMessage(Me.Handle, WM_FONTCHANGE, 0, Nothing)
and
SendMessage(CrystalReportViewer1.Handle, WM_FONTCHANGE, 0, Nothing)
But with both lines, GetLastError return error "126 - The specified module
could not be found"
Any help would be very appreciated.
Thanks,
We have a Windows application that is using Crystal Reports reports
containing Barcode fonts. Those reports are called through reflection into
a Crystal Report Viewer and we need to have the Barcode fonts to be
self-installed at runtime whenever a report is viewed.
I tried the following steps:
Public Shared Sub InstallFonts()
Dim fi As System.IO.FileInfo
Try
Dim res As Integer
fi = New System.IO.FileInfo(\\multi316\oasys\Reports\REQUIRED
FONTS\3of9.ttf)
Dim fiTarget As New System.IO.FileInfo("C:\Windows\Fonts\3OF9.TTF")
If fiTarget.Exists Then Return
' copy the font
fi.CopyTo("C:\Windows\Fonts\3OF9.TTF")
' add the font
res = CreateScalableFontResource(0, "c:\windows\Temp\3OF9.FOT",
"c:\windows\fonts\3OF9.TTF", String.Empty)
res = AddFontResource("C:\Windows\Temp\3OF9.FOT")
If res > 0 Then
' alert all windows that a font was added
SendMessage(New System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE, 0,
Nothing)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Everything looks to be ok as my .FOT file is created and both
AddFontResource and CreateScalableFontResource have a return value of 1
meaning the font was correctly added to the font collection.
The problem I am having is with the final part, the line below keep
executing forever:
SendMessage(New System.IntPtr(HWND_BROADCAST), WM_FONTCHANGE, 0,
Nothing)
I also tried different version like :
SendMessage(Me.Handle, WM_FONTCHANGE, 0, Nothing)
and
SendMessage(CrystalReportViewer1.Handle, WM_FONTCHANGE, 0, Nothing)
But with both lines, GetLastError return error "126 - The specified module
could not be found"
Any help would be very appreciated.
Thanks,