Archive: Change Dialog Text Colour


Change Dialog Text Colour
Hi all,

Im having to change colour in txt in a directory dialog, i think i found a command but it change the background colour instead, and so far whatever i put in is kinda blue or green or black ?

here is what i wanna change colours :

Function ChangeDirTextFunction
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R1 $R0 1006
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\GhostRecon.exe" "path"
StrCmp $R0 "" NotPresent Present
notpresent:
SendMessage $R1 ${WM_SETTEXT} 0 `STR:Welcome To Bobs Map Pack 1.3 Installer$\nInstallation Was Unable To Find The Path To Mods Folder ,$\nBrowse To Your Ghost Recon Mods Folder, And Install There.`
goto done
present:
SetCtlColors $R1 0x000000 0x000741
SendMessage $R1 ${WM_SETTEXT} 0 `STR:Welcome To Bobs Map Pack 1.3 Installer$\nInstallation Did Find The Path To The Mods Folder ,$\nVerify Path is correct, or browse to the right location, And Install There.`
done:
FunctionEnd

Now if the path was found i want the txt to turn green, if its not found i want red txt, how do i do that ?

Oh and using $R0 in both reg and window could mess things up i think ? Though things seem to work, it go down to present, and display colour. You can change to $B or any $xxx if u wanna ?
Thx in advance


The text color is the first of the two numbers, the background color is the second. 0xFF0000 would be red, 0x00FF00 would be green (bit too bright on default backgrounds).

You have to Hide the label and re-display it as otherwise the label isn't repainted properly by Windows (the two texts would overlap).

Furthermore, dialog item IDs with installoptions typically start at 1200, not 1000. However, it's safer to get the HWND of the controls straight from the ini after initializing/creating the dialog.

Here's a full example using MUI+InstallOptions. Uses LogicLib for the if/then/else type statements.

code


outfile 'customtest.exe'

!include 'LogicLib.nsh'
!include 'MUI.nsh'
!include 'winmessages.nsh'

var hwnd

Page Custom CustomPre CustomPost

!insertmacro MUI_LANGUAGE "English"

Function CustomPre
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "textfield.ini"
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "textfield.ini"
Pop $hwnd
!insertmacro MUI_INSTALLOPTIONS_SHOW
FunctionEnd

Function CustomPost
!insertmacro MUI_INSTALLOPTIONS_READ $0 "textfield.ini" "Settings" "State"
${If} $0 == 0
Abort
${ElseIf} $0 == 1
!insertmacro MUI_INSTALLOPTIONS_READ $R1 "textfield.ini" "Field 2" "HWND"
!insertmacro MUI_INSTALLOPTIONS_READ $R0 "textfield.ini" "Field 1" "State"
${If} $R0 == "C:\"
SetCtlColors $R1 0xff0000 "transparent"
ShowWindow $hwnd 0
SendMessage $R1 ${WM_SETTEXT} 0 `STR:You cannot pick C: root!`
ShowWindow $hwnd 1
${Else}
SetCtlColors $R1 0x00cc00 "transparent"
ShowWindow $hwnd 0
SendMessage $R1 ${WM_SETTEXT} 0 `STR:Path OKAY`
ShowWindow $hwnd 1
${EndIf}
${EndIf}
Abort
FunctionEnd

Section
SectionEnd


INI file

[Settings]
NumFields=2

[Field 1]
Type=DirRequest
Flags=NOTIFY
State=DirRequest
Left=12
Right=134
Top=8
Bottom=21

[Field 2]
Type=Label
Text=Label
Left=12
Right=165
Top=30
Bottom=42