• Welcome to PlanetSquires Forums.
 

A blast from the past

Started by John Montenigro, May 07, 2023, 12:40:22 PM

Previous topic - Next topic

John Montenigro

Hi Paul,
In the last 5 or 6 years my projects haven't involved any programming: relocating to South Carolina, changing job and career, finding myself semi-retired, and getting licensed as an Amateur Radio operator...

But I think I'll always keep coming back to programming as my alternative way of being curious and artistic. Not necessarily productive, but certainly a different way of expressing my ideas and I enjoy it.

So I've fired up my PB (10.04.0108) and FireFly (3.70) with Jose Roca includes (III_107). As a warm-up, I'm writing a program for the kids that will use different fonts.

I noticed a problem in FF code when I try to change a textbox font programmatically - sometimes it works, and sometimes it give odd results. I've tried both DDT and API methods (CONTROL SET FONT vs Send Message). It does not matter which fonts are involved - the FF textbox just doesn't always give me the expected font change.

In straight PBWin, there are no problems at all. The font displays as specified during coding, and changes as expected when CONTROL SET FONT changes to a different font.

In FF, the textbox has no problem with any font IF the font is set at design time, but changing textbox font programmatically does not work all the time. Instead of the font being changed, sometimes only the point size or bold attribute changes, but I cannot get the desired font to display.

I've looked everywhere for code snippets, but no joy. I've searched PB, Planet Squires, and Jose Roca forums, but have not found anything mentioning this as an issue.

So I presume I'm doing something wrong, or that I've missed some technique or forgotten some parameter.

I know that FF is an old product, but hey, so am I, and we both keep on working! I don't want to take your attention away from your current projects for something this obscure, so if there's any little guidance you can offer, I'll track it down.

Actually, I've been away from PB/FF for so long, that I don't know anymore what the current state of the art is with the old PB community. Would you be able to point me to an overview of what's current?

Thanks and best regards,
-John Montenigro
Beaufort, SC









Paul Squires

Hi John,

I guess you could say that I am also semi retired these days  :)

I haven't been as active here lately because I am involved in writing a C++ program which has become a great learning experience. Using Visual Studio makes it very easy.

I am not sure what your SetFont issue could be but if you post the code you're using to try to set the font then I will see if I can pinpoint the problem.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

John Montenigro

Thanks Paul! 

As always, I'm so thankful for your work in creating FireFly. No matter what else you do, you've left a great legacy.

#FireFly_Form#  Version=3.70
Locked=0
ClientOffset=0
ClientWidth=401
ClientHeight=246


[ControlType] Form | PropertyCount=24 | zorder=1 | tabindex=0 |
name=frmPopup
classstyles=CS_VREDRAW, CS_HREDRAW, CS_DBLCLKS
windowstyles=WS_POPUP, WS_THICKFRAME, WS_CAPTION, WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_VISIBLE|WS_EX_WINDOWEDGE, WS_EX_CONTROLPARENT, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR
backbitmap=
backbitmapmode=0 - Tiled
backcolor=SYS,15
caption=For review
export=False
height=285
icon=
left=0
mdichild=False
minwidth=0
minheight=0
maxwidth=0
maxheight=0
startupposition=1 - Centered
tabcontrolchild=False
tabcontrolchildautosize=False
tag=
tag2=
top=0
width=417
windowstate=0 - Normal

[ControlType] TextBox | PropertyCount=22 | zorder=2 | tabindex=7 |
name=txtMsg1
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, ES_LEFT, ES_MULTILINE, ES_AUTOHSCROLL, ES_AUTOVSCROLL, ES_READONLY|WS_EX_CLIENTEDGE, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR
backcolor=SYS,5
controlindex=0
font=Courier New,9,0
fontupgrade=False
forecolor=SYS,8
height=54
left=8
locked=False
leftmargin=0
maxlength=0
rightmargin=0
resizerules=
seltext=False
text=
tag=
tag2=
tooltip=
tooltipballoon=False
top=9
width=365

[ControlType] TextBox | PropertyCount=22 | zorder=3 | tabindex=6 |
name=txtMsg2
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, ES_LEFT, ES_MULTILINE, ES_AUTOHSCROLL, ES_AUTOVSCROLL, ES_READONLY|WS_EX_CLIENTEDGE, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR
backcolor=SYS,5
controlindex=0
font=Courier New,9,0
fontupgrade=False
forecolor=SYS,8
height=36
left=8
locked=False
leftmargin=0
maxlength=0
rightmargin=0
resizerules=
seltext=False
text=
tag=
tag2=
tooltip=
tooltipballoon=False
top=109
width=365

[ControlType] CommandButton | PropertyCount=17 | zorder=4 | tabindex=5 |
name=cmdCLOSE
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, BS_TEXT, BS_PUSHBUTTON, BS_NOTIFY, BS_CENTER, BS_VCENTER|WS_EX_LEFT, WS_EX_LTRREADING
cancel=False
caption=CLOSE
controlindex=0
font=Segoe UI,9,0
fontupgrade=False
height=20
left=337
locked=False
resizerules=
tag=
tag2=
tooltip=
tooltipballoon=False
top=212
width=50

[ControlType] CommandButton | PropertyCount=17 | zorder=5 | tabindex=4 |
name=cmdSave
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, BS_TEXT, BS_PUSHBUTTON, BS_NOTIFY, BS_CENTER, BS_VCENTER|WS_EX_LEFT, WS_EX_LTRREADING
cancel=False
caption=SAVE TEXTS
controlindex=0
font=Segoe UI,9,0
fontupgrade=False
height=20
left=255
locked=False
resizerules=
tag=
tag2=
tooltip=
tooltipballoon=False
top=212
width=70

[ControlType] CommandButton | PropertyCount=17 | zorder=1 | tabindex=3 |
name=cmdMoveTextFromMsg2ToMsg1
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, BS_TEXT, BS_PUSHBUTTON, BS_NOTIFY, BS_CENTER, BS_VCENTER|WS_EX_LEFT, WS_EX_LTRREADING
cancel=False
caption=Copy txt up
controlindex=0
font=Segoe UI,9,0
fontupgrade=False
height=25
left=12
locked=False
resizerules=
tag=
tag2=
tooltip=
tooltipballoon=False
top=149
width=83

[ControlType] RichEdit | PropertyCount=19 | zorder=2 | tabindex=2 |
name=reTest1
windowstyles=WS_CHILD, WS_VISIBLE, WS_HSCROLL, WS_VSCROLL, WS_TABSTOP, ES_LEFT, ES_MULTILINE, ES_AUTOHSCROLL, ES_AUTOVSCROLL, ES_WANTRETURN|WS_EX_CLIENTEDGE, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR
controlindex=0
font=Segoe UI,9,0
fontupgrade=False
height=28
left=116
locked=False
leftmargin=0
maxlength=0
rightmargin=0
resizerules=
text=
tag=
tag2=
tooltip=
tooltipballoon=False
top=167
width=250

[ControlType] External {5D834536-1276-7999-766C-398746547920} | PropertyCount=30 | zorder=0 | tabindex=1 |
name=FireTextBox1
windowstyles=WS_CHILD, WS_VISIBLE, WS_TABSTOP, WS_CLIPSIBLINGS, WS_CLIPCHILDREN|WS_EX_LEFT, WS_EX_LTRREADING
about=
custom=
designstyle=0 - Traditional
backcolor=QB,16777215
backhotcolor=QB,16777215
controlindex=0
font=Tahoma,-11,0,0,0,400,0,0,0,0,0,0,0,0
height=28
locked=False
left=33
leftmargin=0
linehotcolor=QB,8388608
linenormalcolor=QB,8421504
readonly=0 - False
resizerules=0
rightmargin=0
rightaligntext=0 - False
seltext=0 - False
showselector=0 - False
showtriangle=1 - True
tag=
tag2=
text=
textcolor=QB,8388608
texthotcolor=QB,8388608
textdisablecolor=QB,8421504
top=205
width=171

[AllCode]

'--------------------------------------------------------------------------------
Function FRMPOPUP_WM_CREATE ( _
                            hWndForm As Dword, _      ' handle of Form
                            ByVal UserData As Long _  ' optional user defined Long value
                            ) As Long
   'we can set font and size during design... 
   '  but how to change font and PT size on the fly?   'txtBox won't change font. need to use RichEdit (or FireEdit?)  
                           
                              
   Local sTemp As String
   Static dThisFont As Dword   'keep track of last font

   'cycle thru loaded fonts   (to see if any will work)
   '-----------------------

   If dThisFont = 0 Then      'first time  
      dThisFont = gfhScout    'default to the handle of my custom font
   Else
      Incr dThisFont          'otherwise, next of the 7 loaded fonts
   End If
   sTemp = "This Font is: " & Str$(dThisFont)  
   

   'richedit control
   'Control Set Font HWND_frmPopup, HWND_frmPopup_reTest1, dThisFont       
   RichEdit_SetFont (HWND_frmPopup_reTest1, "Scout", 12)     'from RichEditCtrl.inc    'this works OK!
   FF_TextBox_SetText (HWND_frmPopup_reTest1, sTemp)      


   'normal txtbox  
   FF_TextBox_SetText (HWND_frmPopup_txtMsg2, sTemp)  
   'Control Set Font HWND_frmPopup, HWND_frmPopup_txtMsg2, dThisFont      'WHY NOT?? textboxes won't change font after creation?
   Control Set Font HWND_frmPopup, IDC_frmPopup_txtMsg2, dThisFont      'WHY NOT?? textboxes won't change font after creation?
'''SendMessage HWND_frmPopup_txtMsg2, %WM_SetFont, dThisFont, 0          ' why bold, and not my font?     
   'SendMessage HWND_frmPopup_txtMsg2, %EM_SETCHARFORMAT, dThisFont, 0          
               '%EM_SETCHARFORMAT ??? see SetRFsize() in "RE font handling sample.txt" 
'   FF_TextBox_SetText (HWND_frmPopup_txtMsg2, sTemp)  
   FF_Control_Redraw (HWND_frmPopup_txtMsg2)    


     
   'is FireTextBox any different?
   'Control Set Font HWND_frmPopup, HWND_frmPopup_FireTextBox1, dThisFont      'WHY NOT??????
   SendMessage HWND_frmPopup_FireTextBox1, %WM_SetFont, dThisFont, 0             ' changes aspect, but not font...
   FF_Control_SetText (HWND_frmPopup_FireTextBox1, sTemp)
   'FF_Control_Redraw (HWND_frmPopup_FireTextBox1)
                           
End Function


'--------------------------------------------------------------------------------
Function FRMPOPUP_CMDMOVETEXTFROMMSG2TOMSG1_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 sTemp As String         
 
   sTemp = FF_TextBox_GetText (HWND_frmPopup_txtMsg2)   
   FF_TextBox_SetText (HWND_frmPopup_txtMsg1, sTemp)
  
   'SO, "6pt Scout" lines up pretty well with "9pt Courier New"
   ' let's try some more tests

End Function




'--------------------------------------------------------------------------------
Function FRMPOPUP_CMDCLOSE_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
   'not sure if this requires another Font New (as in InitializeFonts())                                 
   'Font End gfhScout
   'Font End gfhCourierNew
   '
   'etc...
   '
                                  
   SaveWindowPosition(gsINI_File, hWndForm, "frmPopup")    ' (use a literal for FormName)
   '
   'Do we want to save the texts from the form?  
   '     ADD A BUTTON that sets a GLOBAL...
   '     Check the global here...


'+++++++++++++++++++++++++++++++++
   'close all window, files, etc.
   FF_CloseForm hWndForm       
  
End Function


'============================================================================
Function InitializeFonts() As Long
   'Font New fontname$ [,points!, style&, charset&, pitch&, escapement&] To fhndl

   Font New "Scout"                                      To gfhScout          
   Font New "Arial"                                      To gfhArial        
   Font New "Bodoni MT"                                  To gfhBodoniMT     
   Font New "Book Antiqua"                               To gfhBookAntiqua  
   Font New "Courier New", 18, %ANSI_CHARSET, 0, 0, 0    To gfhCourierNew   
   Font New "Brush Script MT"                            To gfhBrushScriptMT
   Font New "Cooper"                                     To gfhCooper      

   'Font New "Scout" To gfhScout              'global handle for font Scout 
   ''Font New "Latin" , 10, 0, 0, 0, 0 To gfhScout              'global handle for font Scout
   ''     
   ''Font New "CourierNew" To gfhCourierNew                                 'global handle for font CourierNew
   'Font New "Courier New" , 18, %ANSI_CHARSET, 0, 0, 0 To gfhCourierNew  


   '
   Local m As String
   m  = "Font Handles for: " & $CrLf     
   m &= " Scout = "           & Format$(gfhScout, "########") & $CrLf
   m &= " Arial = "           & Format$(gfhArial, "########") & $CrLf
   m &= " Bodoni MT = "       & Format$(gfhBodoniMT, "########") & $CrLf
   m &= " Book Antiqua = "    & Format$(gfhBookAntiqua, "########") & $CrLf
   m &= " Courier New = "     & Format$(gfhCourierNew, "########") & $CrLf
   m &= " Brush Script MT = " & Format$(gfhBrushScriptMT, "########") & $CrLf
   m &= " Cooper = "          & Format$(gfhCooper, "########") & $CrLf
   ? m,,"Font New statements"
End Function


#if 0
'------------------------------------------------------------
'from FF_APPSTART:
'------------------------------------------------------------
'global handles for fonts:
Global gfhScout         As Dword       ' Scout 
Global gfhArial         As Dword       ' Arial
Global gfhBodoniMT      As Dword       ' Bodoni MT
Global gfhBookAntiqua   As Dword       ' Book Antiqua
Global gfhCourierNew    As Dword       ' Courier New
Global gfhBrushScriptMT As Dword       ' Brush Script MT
Global gfhCooper        As Dword       ' Cooper
'------------------------------------------------------------
#endif

The Globals reside in FF_AppStart.
The Initialize Fonts function resides in FF_WinMain.
The form is driven by a simple command button on the Main form: 
Function FRMMAIN_CMDShow_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 m as string
   m &= $CrLf & "row 3 of text"  & $CrLf  & "and row 4" & $CrLf                           
   hFrmPopup = frmPopup_Show(HWND_FRMMAIN, %FALSE)  
   FF_TextBox_SetText (HWND_frmPopup_txtMsg1, m) 
End Function



I'm leaving in the various command syntax statements I've tried.

Since posting above, I've tried other coding methods (String constants for font names, numeric constants for font indexes in a global array, etc.) but to no avail.

The thing most suspicious to me is that the FONT NEW statement returns font handles like 4, 5, 6...  where I thought they would be more cryptic and in a different range. But if they're right, great.

Thanks for taking a look. I appreciate it!
-John


Paul Squires

Hi John,

I haven't loaded your code yet but I can tell right away that you are using PB's own proprietary FONT syntax. That syntax is NOT compatible with the raw Win32 code and handles that FireFly uses. That's why you're getting font handles like 4,5,6 instead of larger numbers that would imply font handles. You would need to create the fonts using FireFly or win32 CreateFont functions and then use the resulting font handle to pass to FireFly textboxes.
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

John Montenigro

I thought I was missing something - what you wrote makes total sense. (It's not always clear which PB syntax is incompatible...)

So I've looked through the FF FunctionsLibrary again, and don't see any commands akin to PB's FONT NEW. Searching on any phrase with FONT returns nothing. The Index likewise shows nothing...

I am aware of FF_CONTROL_SetFont, but I thought that there needed to be the equivalent of FONT NEW... 

DRAT!
After writing the above (based on your saying that I'd need to "create the fonts using FireFly or win32 CreateFont functions"), I went back to FF Functions Library to be 100% sure I hadn't missed any FONT syntax.

I'd been looking for names like "SetFont" or "GetFont", and just now under the General group, I spotted "MakeFontEx", which I admit I have not seen before! (I've been kinda stuck in the Control group). Without your prompting, I would probably not have continued looking...

But the Help entry opened on a function named "FF_GetFontInfo" and I thought "What's this? a name mismatch?"
Finally reading all the way down the page, I count a total of FOUR font functions under that header:
FF_GetFontInfo, FF_EnumCharSet, FF_MakeFontEx_Internal, and MakeFontEx.
After a brief examination, it appears that MakeFontEx calls each of them and is the main routine to get acquainted with. 


Hmm... now looking in FF's CodeStore folders, I also see FF_UsingLargeFonts.inc...  I will also play with that...


Also, a quick search on the forum for MakeFontEx returns a bunch of threads that I will also explore, some with code snippets and more. 


SO, I should be good now... I don't think there's any need for you to mess with my code; I'm anticipating setting my home-brew font in a textbox very soon!

Thanks again for the guidance!
-John

(Any way to rename the subject of this thread to make it more useful to future searches?) 





John Montenigro

OK, I'm now able to change fonts in normal, richedit, and FireEdit textboxes.
After I take out all my experimentation code, I'll post clean code for "final review", and to be available for future searches.

-John