I'm trying to build a tiny app to display the difference between two different barcode fonts. The textbox is first loaded with string data and then a "swap" button sets the textbox font to the other font.
It gives a nice visual comparison between the two fonts.
However, it fails after the third click when the textbox reverts to a text font.
Why does the textbox lose it?
'In AppStart -------------------
Global hFontS As Dword
Global hFontC As Dword
'In WinMain --------------------
hFontS=FF_MakeFontEX( "USPSIMBStandard", 16, %FALSE, %FALSE, %FALSE, %FALSE )
hFontC=FF_MakeFontEX( "USPSIMBCompact", 14, %FALSE, %FALSE, %FALSE, %FALSE )
'In Form1 -----------------------
Function FORM1_CMDSWAP_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
Local btnTag As String
btnTag=FF_Control_GetTag( HWND_FORM1_CMDSWAP )
Select Case btnTag
Case "S"
'set tag and caption of swap button
FF_Control_SetTag( HWND_FORM1_CMDSWAP, "C" )
FF_Control_SetText( HWND_FORM1_CMDSWAP, "Show Standard Size" )
'set font of textbox
FF_Control_SetFont( HWND_FORM1_TIMS, hFontC )
Case "C"
'set tag and caption of swap button
FF_Control_SetTag( HWND_FORM1_CMDSWAP, "S" )
FF_Control_SetText( HWND_FORM1_CMDSWAP, "Show Compact Size" )
'set font of textbox
FF_Control_SetFont( HWND_FORM1_TIMS, hFontS )
End Select
'FF_Control_Redraw( HWND_FORM1_TIMS ) 'fails with or without redraw
End Function
Waht happens the third time? Nothing? Or something wrong? And if so, what?
Wilko
The FF function FF_Control_SetFont will delete the font that the control holds prior to applying the new font. Therefore, your global font handle will become invalid when it is subsequently tried to be applied to the control (ie. the third time).
The 'solution' in your case, because you are using global font handles, is to simply use the WM_SETFONT message directly on your control rather than FF_Control_SetFont:
SendMessage hWndControl, %WM_SETFONT, hFontS, %TRUE
Hope that makes it work for you.
Thanks Paul, that worked. This was my first effort with setting fonts outside of properties.
The barcode I am working with is the US Postal Service Intelligent Mail barcode (IMB). It formats the output of the encoder dll.
The encoder software and fonts are available for a variety of systems.
See: https://ribbs.usps.gov/onecodesolution/download.cfm (https://ribbs.usps.gov/onecodesolution/download.cfm) for a listing of available systems.
The encoding process is pretty involved, which is why they provide the dll. Here's a gem from the encoding technical guide:
QuoteAn 11-bit CRC Frame Check Sequence (FCS) value shall be generated by applying the Generator Polynomial (0xF35) to the rightmost 102 bits of the Binary Data.
And all this was develped for the USPS by a company in Ottawa.
Canada! Great Software! Great Hockey! and weather.
Quote from: Pat Dooley on October 02, 2010, 08:21:48 AM
Canada! Great Software! Great Hockey! and weather.
Well, two out three ain't bad.... the weather here in Newfoundland could be better !!!! :)