Changing Title and Subtitle Fonts on MUI Pages

From NSIS Wiki

Author: Red Wine (talk, contrib)


Description

The following example on how to change the title and subtitle fonts under certain target's screen resolutions provived for the subject at this forum thread.
Affects the parent dialog of MUI standard pages.

The Code

!define APP_NAME 'Test'
 
name ${APP_NAME}
outfile '${APP_NAME}.exe'
showinstdetails show
InstallDir '$PROGRAMFILES\${APP_NAME}'
 
!include 'mui.nsh'
 
!insertmacro MUI_PAGE_WELCOME
 
!define MUI_PAGE_CUSTOMFUNCTION_PRE ChangeFonts
!insertmacro MUI_PAGE_LICENSE '${NSISDIR}\License.txt'
 
!insertmacro MUI_PAGE_COMPONENTS
 
!insertmacro MUI_PAGE_DIRECTORY
 
!insertmacro MUI_PAGE_INSTFILES
 
!insertmacro MUI_PAGE_FINISH
 
!insertmacro MUI_LANGUAGE "English"
 
 
function ChangeFonts
; Get users screen resolution and if is equal or less than 1024
; do not change fonts, if greater then change fonts to 10.
##### uncomment the following 2 lines to get users screen res #####
;System::Call 'user32::GetSystemMetrics(i 0) i .r0'
;IntCmp $0 1024 end end 0
CreateFont $0 "$(^Font)" "10" "700"
SendMessage $mui.Header.Text ${WM_SETFONT} $0 0
 
CreateFont $0 "Tahoma" "10" "500"
SendMessage $mui.Header.SubText ${WM_SETFONT} $0 0
end:
functionend
 
section !Required Section
SectionIn RO
sectionend
 
Section /o Optional
 
SectionEnd

License

This code example is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this code.

Permission is granted to anyone to use this code for any purpose, including commercial applications, and to alter it and redistribute it freely.

Personal tools
donate