FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with Choose font
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Problem with Choose font
Posted: Thu Apr 20, 2023 07:38 AM

When I recall Choosefont() I not see the font I select before

How I can to show the font I select before ?

I call with aFont := ChooseFont(,@nColorFont ) where nColorFont is the color

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Problem with Choose font
Posted: Thu Apr 20, 2023 11:26 PM
Fijate si sirve asi:
Code (fw): Select all Collapse
#include "FiveWin.ch"
function Main()

   local oWnd, oFont, oBtn, oGet, nColor := 0

   DEFINE DIALOG oWnd TITLE "Elegir font" 
   oFont:= oWnd:oFont

   @ 10,10 GET oGet VAR nColor PICTURE "999999999" RIGHT of oWnd PIXEL 

   @ 30,10 BUTTON oBtn PROMPT "Elegir Font" ACTION ElegirFont(@oFont,@nColor) OF oWnd SIZE 30,10 PIXEL

   ACTIVATE DIALOG oWnd 

return nil

//----------------------------------------------------------------------------//

function ElegirFont(oFont,nColor)

oFont := ChooseFont(oFont,@nColor)

return nil
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Problem with Choose font
Posted: Fri Apr 21, 2023 09:43 AM

I have different on my dialog I use BTNBMP control to show name of font and sizes

 cFontName   := oBrowse:aArraydata[nRecord][15]

 nFontSize   := oBrowse:aArraydata[nRecord][16]

 lUnderline  := oBrowse:aArraydata[nRecord][17]

 lStrikeOut  := oBrowse:aArraydata[nRecord][18]

 lBold       := oBrowse:aArraydata[nRecord][19]

 lItalic     := oBrowse:aArraydata[nRecord][20]

 nColorFont  := oBrowse:aArraydata[nRecord][21]

@ nRow,5 BTNBMP aGet[15] OF oDlg;

            PROMPT cFontName  RIGHT;

            SIZE 250, 23  PIXEL FLAT NOROUND

@ nRow,215 BTNBMP aGet[16] OF oDlg;

            PROMPT STR(nFontSize) LEFT;

            SIZE 50, 23  PIXEL FLAT NOROUND







   @ nRow, 255 BUTTONBMP oBtnSel[4]  RESOURCE "REP_FONT"  FLAT SIZE 20, 23  OF ooDlgPIXEL ;

     ACTION (aFont  := ChooseFont(@cFontName,@nColorFont ),;

                                cFontName:=aFont[LF_FACENAME],;

                               nFontSize:=IF( aFont[LF_HEIGHT ]!=NIL,FontHeightInPoints( aFont[LF_HEIGHT ]),0) ,;

                              lBold:= IIF(aFont[LF_WEIGHT]=700,.t.,.f.) ,;

                             lItalic:= aFont[LF_ITALIC],;

                            lUnderline:=aFont[LF_UNDERLINE],;

                           lStrikeout:=aFont[ LF_STRIKEOUT ],;

                       aGet[15]:settext(cFontName),;

                       aGet[16]:settext(str(nFontSize)),;

                       aGet[15]:refresh(),;

                       aGet[16]:refresh())

First run ok then On modify the choosefont not take the font I save before

I sent you a minitest

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Problem with Choose font
Posted: Fri Apr 21, 2023 04:40 PM
hi Silvio,

as i understand the 1st Parameter is a Array or Object of used Font
Code (fw): Select all Collapse
   aFont := ChooseFont( { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                          oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                          oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                          oFont:nOutPrecision, oFont:nClipPrecision,;
                          oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName },;
                          @nNewColor )
later we can use Array aFont to create New Font
Code (fw): Select all Collapse
   if !Empty( aFont[ LF_FACENAME ] )
      oNewFont = TFont():New( aFont[ LF_FACENAME ],, aFont[ LF_HEIGHT ], .f.,;
                           ! ( aFont[ LF_WEIGHT ] == FW_NORMAL ),;
                           aFont[ LF_ESCAPEMENT ], aFont[ LF_ORIENTATION ],;
                           aFont[ LF_WEIGHT ], aFont[ LF_ITALIC ],;
                           aFont[ LF_UNDERLINE ], aFont[ LF_STRIKEOUT ],;
                           aFont[ LF_CHARSET ], aFont[ LF_OUTPRECISION ],;
                           aFont[ LF_CLIPPRECISION ], aFont[ LF_QUALITY ],,;
                           aFont[ LF_PITCHANDFAMILY ] )
and set new Color
Code (fw): Select all Collapse
      o:SetFormat( oNewFont, nNewColor )
greeting,

Jimmy
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Problem with Choose font
Posted: Mon Apr 24, 2023 07:21 PM
Jimmy wrote:hi Silvio,

as i understand the 1st Parameter is a Array or Object of used Font
Code (fw): Select all Collapse
   aFont := ChooseFont( { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                          oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                          oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                          oFont:nOutPrecision, oFont:nClipPrecision,;
                          oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName },;
                          @nNewColor )
later we can use Array aFont to create New Font
Code (fw): Select all Collapse
   if !Empty( aFont[ LF_FACENAME ] )
      oNewFont = TFont():New( aFont[ LF_FACENAME ],, aFont[ LF_HEIGHT ], .f.,;
                           ! ( aFont[ LF_WEIGHT ] == FW_NORMAL ),;
                           aFont[ LF_ESCAPEMENT ], aFont[ LF_ORIENTATION ],;
                           aFont[ LF_WEIGHT ], aFont[ LF_ITALIC ],;
                           aFont[ LF_UNDERLINE ], aFont[ LF_STRIKEOUT ],;
                           aFont[ LF_CHARSET ], aFont[ LF_OUTPRECISION ],;
                           aFont[ LF_CLIPPRECISION ], aFont[ LF_QUALITY ],,;
                           aFont[ LF_PITCHANDFAMILY ] )
and set new Color
Code (fw): Select all Collapse
      o:SetFormat( oNewFont, nNewColor )

Please help because it not run ok

I have the data in a browse

Code (fw): Select all Collapse
    cFontName   := oBrowse:aArraydata[nRecord][15]
     nFontSize   := oBrowse:aArraydata[nRecord][16]
     lUnderline  := oBrowse:aArraydata[nRecord][17]
     lStrikeOut  := oBrowse:aArraydata[nRecord][18]
     lBold       := oBrowse:aArraydata[nRecord][19]
     lItalic     := oBrowse:aArraydata[nRecord][20]
     nColorFont  := oBrowse:aArraydata[nRecord][21]
only in the edit i create aFont array

aFont:= { , , ,, , lItalic,lUnderline, lStrikeOut, ,, ,, , cFontName }

then in the get control i do like this



Code (fw): Select all Collapse
 @ nRow,5  BTNBMP aGet[15] OF oRigaModulo;
                PROMPT cFontName  RIGHT;
                SIZE 250, 23  PIXEL FLAT NOROUND

 @ nRow,215  BTNBMP aGet[16] OF oRigaModulo;
                PROMPT STR(nFontSize) LEFT;
                SIZE 50, 23  PIXEL FLAT NOROUND

@ nRow, 255 BUTTONBMP oBtnSel[4]  RESOURCE "REP_FONT"  FLAT SIZE 20, 23  OF oRigaModulo PIXEL ;
         ACTION (aFont  := ChooseFont(aFont,@nColorFont ),;
                           cFontName:=aFont[LF_FACENAME],;
         nFontSize:=IF( aFont[LF_HEIGHT ]!=NIL,FontHeightInPoints( aFont[LF_HEIGHT ]),0) ,;
                           lBold:= IIF(aFont[LF_WEIGHT]=700,.t.,.f.) ,;
                           lItalic:= aFont[LF_ITALIC],;
                           lUnderline:=aFont[LF_UNDERLINE],;
                           lStrikeout:=aFont[ LF_STRIKEOUT ],;
                           aGet[15]:settext(cFontName),;
                           aGet[16]:settext(str(nFontSize)),;
                           aGet[15]:refresh(),;
                           aGet[16]:refresh())
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Problem with Choose font
Posted: Wed Apr 26, 2023 11:03 PM
hi Silvio,
Silvio.Falconi wrote:I have the data in a browse
Code (fw): Select all Collapse
    cFontName   := oBrowse:aArraydata[nRecord][15]
     nFontSize   := oBrowse:aArraydata[nRecord][16]
     lUnderline  := oBrowse:aArraydata[nRecord][17]
     lStrikeOut  := oBrowse:aArraydata[nRecord][18]
     lBold       := oBrowse:aArraydata[nRecord][19]
     lItalic     := oBrowse:aArraydata[nRecord][20]
     nColorFont  := oBrowse:aArraydata[nRecord][21]
only in the edit i create aFont array
Code (fw): Select all Collapse
aFont:= { , , ,, , lItalic,lUnderline, lStrikeOut, ,, ,, , cFontName }
then in the get control i do like this
as i understand 1st Element is "Start-Point" so aFont must be "full filled" before pass it
but your aFont seems not to include "all"
Code (fw): Select all Collapse
       aFont := { oFont:nInpHeight, oFont:nInpWidth, oFont:nEscapement,;
                              oFont:nOrientation, oFont:nWeight, oFont:lItalic,;
                              oFont:lUnderLine, oFont:lStrikeOut, oFont:nCharSet,;
                              oFont:nOutPrecision, oFont:nClipPrecision,;
                              oFont:nQuality, oFont:nPitchFamily, oFont:cFaceName }
i do have a oFont Object which also can be passed as 1st Parameter
greeting,

Jimmy

Continue the discussion