Fonts in Static Controls

From NSIS Wiki

Author: techkid (talk, contrib)


Description

This code was developed with working on NSIS Update the Static Controls like Label can be Change to different fonts, size, and weights. When NSIS Update uses a function it make the label bold the script is striped down but show the functionality. Please note that ListView Controls doesn't update like it really should be no matter it not a static control but it works.

The Script

Below is a complete script to compile and run:

Name "Change Font"
OutFile "ChangeFont.exe"
Caption "Change Font"
ShowINSTDetails show
 
!include "${NSISDIR}\Include\WinMessages.nsh"
 
!macro NSISU_TASK_TEXT_BOLD CONTROL
  FindWindow $R4 "#32770" "" $HWNDPARENT
  GetDlgItem $R4 $R4 ${CONTROL}
  SendMessage $R4 ${WM_SETFONT} $R1 0
!macroEnd
 
!macro NSISU_TASK_TEXT_NORM CONTROL
  FindWindow $R4 "#32770" "" $HWNDPARENT
  GetDlgItem $R4 $R4 ${CONTROL}
  SendMessage $R4 ${WM_SETFONT} $R0 0
!macroEnd
 
Function CreateFonts
  CreateFont $R0 "Arial" "8" "0"
  CreateFont $R1 "Arial" "8" "600"
FunctionEnd
 
Section
 
  call CreateFonts
  MessageBox MB_YESNO "Would you like to make it bold?" IDYES 0 IDNO EXIT
    !insertmacro NSISU_TASK_TEXT_BOLD 1006
    !insertmacro NSISU_TASK_TEXT_BOLD 1016
    DetailPrint "Bold Text"
    DetailPrint "Font: Arial"
    DetailPrint "Size: 8pt"
    DetailPrint "Weight: 800"
    MessageBox MB_YESNO "Would you like to make it Normal?" IDYES 0 IDNO EXIT
    !insertmacro NSISU_TASK_TEXT_NORM 1006
    !insertmacro NSISU_TASK_TEXT_NORM 1016
  EXIT:
 
SectionEnd
Personal tools
donate