choosefont

choosefont

Postby Silvio.Falconi » Thu Nov 30, 2023 10:33 am

When open choosefont ( on first time) not set the size of font I passed as you can see on this picture

How it is possible ?

Image


the small test

Code: Select all  Expand view  RUN
#include "FiveWin.ch"
function Main()

   local oWnd, oFont, oBtn, oGet, nColor := 0
    local cFontName :="Arial"     ,;
          nFontSize := 8     ,;
          lUnderline:= .f.     ,;
          lStrikeOut:= .f.     ,;
          lBold      := .f.    ,;
          lItalic     := .f.   ,;
          nColorFont   := 0  
aFont:= {,,,,nFontSize,lItalic,lUnderLine,lStrikeOut,,,,,,cFontName}
local aGet:= array(3)

   DEFINE DIALOG oWnd TITLE "Call font"  size 400,300

     @ 10, 5 GET aGet[1] VAR cFontName  SIZE 100,12 PIXEL OF oWnd
     @ 30, 5 GET aGet[2] VAR nFontSize SIZE 20,12 PIXEL OF oWnd PICTURE "999"
     @ 60, 5 GET aGet[3] VAR nColorFont SIZE 20,12 PIXEL OF oWnd


   @ 90,10 BUTTON oBtn PROMPT "Call Font" ;
       ACTION (aFont  := Select_Font(@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[1]:refresh(),;
          aGet[2]:refresh(),;
          aGet[3]:refresh());
          OF oWnd SIZE 30,10 PIXEL

   ACTIVATE DIALOG oWnd center

return nil

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

function Select_Font(aFont,nColor)
 aFont  := ChooseFont(aFont,@nColor)
 return aFont
//----------------------------------------------------------------------------//
 function FontHeightInPoints( nHeight )
   local nPoints, hDC
   nPoints := Round( Abs( nHeight ) * 72 / GetDeviceCaps( hDC := GetDC( 0 ), 90 ), 0 )
   ReleaseDC( 0, hDC )
   return nPoints
//----------------------------------------------------------------------------/
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 23 guests