How to use Segoe MDL2 icons on Win 7 ?

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby Giovany Vecchi » Sat Aug 31, 2019 1:21 pm

nageswaragunupudi wrote:Why do you have to make any changes to buttonbmp class and change many functions?

If your FWH version is not very old, it is very easy to use Segoe MDL2 Assets (if installed) in the place of bitmaps on BTNBMP and also BUTTONBMP, without any changes in the FWH library.

Please try this small test program
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oFont

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 270,280 PIXEL TRUEPIXEL FONT oFont ;
      TITLE "Segoe MDL2 Assets on Buttons"

   @  40, 40 BTNBMP PROMPT "First" RESOURCE 0xE100 SIZE 80,80 PIXEL OF oDlg FLAT
   @  40,150 BTNBMP PROMPT "Last"  RESOURCE 0xE101 SIZE 80,80 PIXEL OF oDlg FLAT

   @ 160, 40 BUTTONBMP PROMPT "Edit" RESOURCE 0xE104 SIZE 80,80 PIXEL OF oDlg TEXTBOTTOM
   @ 160,150 BUTTONBMP PROMPT "Save" RESOURCE 0xE105 SIZE 80,80 PIXEL OF oDlg TEXTBOTTOM

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil
 



Hi Mr Rao. I changed the tButtomBmp class to make the buttons static, so I edit every state transformation at runtime.

To work on Windows Seven, I renamed the font Segoe MDL2 Assets to Segoe MDL2 Assets Seven and at the beginning of the program I execute:

Code: Select all  Expand view
FUNCTION G_SYMBOL_INSTALL()
  Local hDc, aFonts
  Local lc_oDb_FrFix

  If IsWindows10()
    Return nil
  EndIf
 
  hDC    := GetDC( WndMain():hWnd )
  aFonts := ASort( GetFontNames( hDC ) )
  ReleaseDC( WndMain():hWnd, hDC )

  if AScan( aFonts, "Segoe MDL2 Assets Seven" ) > 0
    Return Nil
  endif

  lmkdir(DIR_TEMP()+"Fonts")
  lc_oDb_FrFix := DB_FR_FIX():OpenRdd()
  lc_oDb_FrFix:DB_FR_FIX_GetCompress(16,DIR_TEMP(),DIR_TEMP()+"Fonts")
  lc_oDb_FrFix:End()
 
  AddFontResource(DIR_TEMP()+"Fonts\segmdl2_7.ttf")
  AddFontResource(DIR_TEMP()+"Fonts\segoeuil_7.ttf")
  AddFontResource(DIR_TEMP()+"Fonts\seguisym_7.ttf")
 
RETURN NIL


In the ShowSymbol function in ImgTxtio.prg has these changes.
Code: Select all  Expand view
  if nChr > 8000 //nAnd( nChr, 0xF000 ) == 0xE000
      if lSegoe
         nHeight     := Int( Min( aRect[ 1 ] - aRect[ 3 ], aRect[ 4 ] - aRect[ 2 ] ) * 0.6 )//0.48 ) ///0.6 )
         /// Giovany
         cFace    := If( lWin10, "Segoe MDL2 Assets", "Segoe MDL2 Assets Seven" ) // Change as Windows
         DEFINE FONT oFont NAME cFace SIZE 0, -nHeight
         if oFont:hFont == 0
            lSegoe  := .f.
         else
            //? "ccc"
            cText    := HB_UTF8CHR( nChr )
            SetBkMode( hDC, 1 )
            If lWin10
              x     := Int( 0.1 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            Else
              x     := Int( 0.14 * ( aRect[ 4 ] - aRect[ 2 ] ) )
            EndIf
            aRect[ 2 ]  += x
            aRect[ 4 ]  += x
            DrawTextEx( hDC, cText, aRect, DT_CENTER + DT_VCENTER + DT_SINGLELINE, oFont:hFont, nClrText )
         endif
         RELEASE FONT oFont
      endif
   elseif 1==4 //( nFont := nAnd( nChr, 0xFF0000 ) ) <= 0x30000
      nHeight     := Int( Min( aRect[ 1 ] - aRect[ 3 ], aRect[ 4 ] - aRect[ 2 ] ) * 1.0 )
      nChr     := nAnd( nChr, 0xFFFF )
      nFont    /= 0x10000
      cFace    := "Wingdings" + Str( nFont, 2 )
      DEFINE FONT oFont NAME cFace SIZE 0, -nHeight CHARSET 2
      cText    := Chr( nChr )
      SetBkMode( hDC, 1 )
      DrawTextEx( hDC, cText, aRect, DT_CENTER + DT_VCENTER + DT_SINGLELINE, oFont:hFont, nClrText )
      RELEASE FONT oFont
   endif
 


Now the tButtonBmp class changed

ftp://Contrib:123@giovanyvecchi.no-ip.info:97/buttonb_2018_02.prg
User avatar
Giovany Vecchi
 
Posts: 222
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby nageswaragunupudi » Sat Aug 31, 2019 1:40 pm

Code: Select all  Expand view
  @  40, 40 BTNBMP oBtn PROMPT "First" RESOURCE 0xE100 SIZE 80,80 PIXEL OF oDlg FLAT ;
               COLOR CLR_HBLUE // text color
   WITH OBJECT oBtn
      :nClrBorder    := CLR_GREEN  //  border color
      :bColorMap     := { || { { CLR_BLACK, CLR_HRED } } }  // image color
   END
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby Giovany Vecchi » Sat Aug 31, 2019 1:45 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
  @  40, 40 BTNBMP oBtn PROMPT "First" RESOURCE 0xE100 SIZE 80,80 PIXEL OF oDlg FLAT ;
               COLOR CLR_HBLUE // text color
   WITH OBJECT oBtn
      :nClrBorder    := CLR_GREEN  //  border color
      :bColorMap     := { || { { CLR_BLACK, CLR_HRED } } }  // image color
   END
 


Yes, Mr. Rao, I know it works this way. I made the changes so as not to have to change all my prgs.
Another, when it is Windows Seven, has to call another source.
User avatar
Giovany Vecchi
 
Posts: 222
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

Re: How to use Segoe MDL2 icons on Win 7 ?

Postby Marcelo Roggeri » Sat Aug 31, 2019 1:53 pm

Muchas gracias Mr. Rao
FWH - Harbour - BCC7 - PellesC
User avatar
Marcelo Roggeri
 
Posts: 342
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests