Skip to content
⌘ NSIS Forum Archive

Change Colors

21 posts

RoMZERO#

Change Colors

How can i change:
- text color
- background color
- space components color

in this window ?
Afrow UK#
You need to use Resource Hacker to get the dialogue id numbers (search Google).

Then use GetDlgItem, SetCtlColors etc to change the colours of those items.

-Stu
RoMZERO#
I have a problem: the DlgItem have standard color.

Why don't work ?

This is only an example


Var HWND
Var DLGITEM

Function .oninit

FindWindow $HWND "#32770" "" $HWNDPARENT
; PROGRESSBAR
GetDlgItem $DLGITEM $HWND 1004
SetCtlColors $DLGITEM C4B550 3E4637
; INSTFILESPAGE
GetDlgItem $DLGITEM $HWND 1016
SetCtlColors $DLGITEM FFFFFF 3E4637

FunctionEnd
Afrow UK#
Ok, just realised you are calling it in .onInit.
.onInit is called before the dialogue is shown and thus the dialogue does not exist yet. You need to use your code in .onGUIInit or a Section (for InstFiles page) instead.

-Stu
RoMZERO#
i can't use .onGUIInt because with MUI i have this error message Error: Function named ".onGUIInit" already exists.


I use this but don't work 🙁

why ?

!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit

Function myGuiInit

FindWindow $HWND "#32770" "" $HWNDPARENT
; PROGRESSBAR
GetDlgItem $DLGITEM $HWND 1004
SetCtlColors $DLGITEM 0xC4B550 0x3E4637
; INSTFILESPAGE
GetDlgItem $DLGITEM $HWND 1016
SetCtlColors $DLGITEM 0xFFFFFF 0x3E4637

FunctionEnd
Afrow UK#
I guess Modern UI already uses .onGUIInit for it's own purposes.

Use this instead (from MUI readme)

!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit

Function myGUIInit
...your own code...
FunctionEnd
-Stu
Afrow UK#
For your code, as you are trying to change colours on the InstFiles page, stick the code in a Section (like I said earlier), or in the page show function (like Lobo stated).

-Stu
RoMZERO#
sorry, but i don't understand

this is full script

where is my error ?


;--------------------------------
;Include Modern UI

!include "MUI.nsh"
!include "Sections.nsh"

;--------------------------------
;General

;Name and file
Name "GCF Backup v0.1"
OutFile "GCFBackup.exe"

ShowInstDetails show

;Get installation folder from registry if available
InstallDirRegKey HKLM "Software\Valve\Steam" "InstallPath"

SetCompressor lzma

Var HWND
Var DLGITEM

;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING
!define MUI_COMPONENTSPAGE_NODESC
!define MUI_LICENSEPAGE_BGCOLOR "3E4637"
;!define MUI_INSTFILESPAGE_COLORS "C4B550 3E4637"
;!define MUI_INSTFILESPAGE_PROGRESSBAR "colored"
;C4B550 giallo
;4C5844 verde chiaro
!define MUI_COMPONENTSPAGE_CHECKBITMAP "bmp\check.bmp"
!define MUI_BGCOLOR "3E4637"
!define MUI_ICON "bmp\Icon.ico"
!define MUI_WELCOMEFINISHPAGE_BITMAP "bmp\welcome.bmp"
;!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
!define MUI_CUSTOMFUNCTION_COMPONENTS_SHOW "CompColor"

;--------------------------------
;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License\License.rtf"
Page components "CompColor"
;!insertmacro MUI_PAGE_COMPONENTS
;!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "GCF Vari" SecVari
ReadINIStr $R1 "$EXEDIR\CFG\config.ini" "GCF" "GCF Vari"
nsExec::ExecToLog '"$EXEDIR\7Z\7za.exe" x "$EXEDIR\7Z\$R1.7z" -aoa -y "-o$INSTDIR\SteamApps\"'
SectionEnd
...
...

Function CompColor
;--------------------------------
; Colors

FindWindow $HWND "#32770" "" $HWNDPARENT
; PROGRESSBAR
GetDlgItem $DLGITEM $HWND 1022
SetCtlColors $DLGITEM 0x00C4B550 0x003E4637
; INSTFILESPAGE
GetDlgItem $DLGITEM $HWND 1032
SetCtlColors $DLGITEM 0x00FFFFFF 0x003E4637

FunctionEnd

Function .onInit
;--------------------------------
; Splash Screen

SetOutPath $TEMP
File /oname=spltmp.bmp "bmp\splash.bmp"
File /oname=spltmp.wav "snd\hev_logon.wav"

splash::show 5500 $TEMP\spltmp

Pop $0

Delete $TEMP\spltmp.bmp
Delete $TEMP\spltmp.wav

;--------------------------------
; Find Process: Steam

FindProcDLL::FindProc "steam.exe"
Pop $R0
StrCmp $R0 "605" 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"Code $R0: Unable to search for process" \
IDABORT
Quit
StrCmp $R0 "606" 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"Code $R0: Unable to identify system type" \
IDABORT
Quit
StrCmp $R0 "607" 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"Code $R0: Unsupported OS" \
IDABORT
Quit
StrCmp $R0 "632" 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"Code $R0: Process name is invalid" \
IDABORT
Quit
StrCmp $R0 "1" 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"Code $R0: 'Steam.exe' process was found, close it" \
IDABORT
Quit

;--------------------------------
; Error Check

StrCmp $INSTDIR "" 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"Steam not installed, install it before launch GCF Backup" \
IDABORT
Quit
IfFileExists "$EXEDIR\CFG\config.ini" +3 0
MessageBox MB_OK|MB_ICONSTOP \
"Error: 'config.ini' not found" \
IDABORT
Quit
IfFileExists "$EXEDIR\7Z\7za.exe" +3 0
MessageBox MB_OK|MB_ICONSTOP \
"Error: '7za.exe' not found" \
IDABORT
Quit

;--------------------------------
; Components Check

ReadINIStr $R1 "$EXEDIR\CFG\config.ini" "GCF" "GCF Vari"
IfFileExists "$EXEDIR\7Z\$R1.7z" +7
!insertmacro UnSelectSection "${SecVari}"
SectionSetText ${SecVari} ""

...
...

FunctionEnd
Afrow UK#
From MUI readme:
These defines should be set before inserting a page macro.

MUI_PAGE_CUSTOMFUNCTION_PRE function
MUI_PAGE_CUSTOMFUNCTION_SHOW function
MUI_PAGE_CUSTOMFUNCTION_LEAVE function
-Stu
Afrow UK#
Here you are.
(Please attach scripts in future)

-Stu
RoMZERO#
work fine 🙂

tnx for all, you are very kind 🙂

last question: how can i edit the script for change color of the gray space ? (look the image)