How to use Segoe MDL2 icons on Win 7 ?

User avatar
Giovany Vecchi
Posts: 129
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

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

Post by Giovany Vecchi »

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

#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

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

   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.i ... 018_02.prg
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

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

Post by nageswaragunupudi »

Code: Select all

   @  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
Giovany Vecchi
Posts: 129
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

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

Post by Giovany Vecchi »

nageswaragunupudi wrote:

Code: Select all

   @  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
Marcelo Roggeri
Posts: 275
Joined: Sat Jul 22, 2006 9:04 pm
Location: Venado Tuerto - Santa Fe -Argentina
Contact:

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

Post by Marcelo Roggeri »

Muchas gracias Mr. Rao
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
Post Reply