How to change the backgroung color and Font in the Components Page's Tree-view

From NSIS Wiki
Jump to navigationJump to search
Author: Joel (talk, contrib)


Screenshots

classic background
New


The Script

;Classic UI
!define TVM_SETBKCOLOR 0x111D ;Window Message Background
!define TVM_SETTEXTCOLOR 0x111E ;Window Message Text
 
!include "winmessages.nsh"
 
Name "dummy"
OutFile "dummy.exe"
XPStyle on
ShowInstDetails show
Page components "" "CompShowProc" ""
Page instfiles
 
Function "CompShowProc"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1032
SendMessage $0 ${TVM_SETBKCOLOR} 0 0x00BAB0A6
SendMessage $0 ${TVM_SETTEXTCOLOR} 0 0xFFFFFF
CreateFont $1 "Comic Sans Ms" 8 0
SendMessage $0 ${WM_SETFONT} $1 0
FunctionEnd
 
SubSection "SectionParent"
 
Section "Section1"
; void
SectionEnd
 
Section "Section2"
; void
SectionEnd
 
SubSectionEnd
;Modern UI
 
!define TVM_SETBKCOLOR 0x111D ;Window Message Background
!define TVM_SETTEXTCOLOR 0x111E ;Window Message Text
 
!include "MUI.nsh"
 
Name "dummy"
OutFile "dummy.exe"
XPStyle on
ShowInstDetails show
 
!define MUI_PAGE_CUSTOMFUNCTION_SHOW "CompShowProc"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
 
!insertmacro MUI_LANGUAGE "English"
 
Function "CompShowProc"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1032
SendMessage $0 ${TVM_SETBKCOLOR} 0 0x00BAB0A6
SendMessage $0 ${TVM_SETTEXTCOLOR} 0 0xFFFFFF
CreateFont $1 "Comic Sans Ms" 8 0
SendMessage $0 ${WM_SETFONT} $1 0
FunctionEnd
 
SubSection "SectionParent"
 
Section "Section1"
; void
SectionEnd
 
Section "Section2"
; void
SectionEnd
 
SubSectionEnd