Archive: colored text input


colored text input
can anybody help me on how to change the background color of a text-control in both nsDialogs and InstallOptions?

thanks!


1.- Get the dialog item hwnd (FindWindow)
2.- SetCtlrColors
http://nsis.sourceforge.net/Change_t...r_in_textboxes


i tried the following code to change the color of Field 4

        !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioA.ini"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1203 ;1200 + Field number - 1
SetCtlColors $0 0x00BAB0A6 0x000000

the code doesn't have any effect on the text field

maybe it's not possible for io-pages as there are no pre-functions for custom pages?


Hmm... Perhaps you need to tweak the colors before actually displaying the page?

Not sure if this will work, but try it this way:


!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "ioA.ini"
pop $0 ; HWND of dialog
ReadIniStr $0 "$PLUGINSDIR\ioA.INI" "Field 4" "HWND"
SetCtlColors $0 0x00BAB0A6 0x000000
!insertmacro MUI_INSTALLOPTIONS_SHOW

i already tried using the code before displaying the page. isn't HWND in an io.ini something from IoEx?

however, your code produces a nice dr. watson message. for testing purposes i removed everything but MUI_INSTALLOPTIONS_INITDIALOG - it actually seems responsible for the crash.

:(


I got this from the stock InstallOptions readme file:

HWND/HWND2:
After initDialog returns, this will contain the HWND of the control created by this field. It can be used instead of FindWindow and GetDlgItem. HWND2 contains the HWND of an additional control, such as the browse button.
I got my code idea from the example of changing the font (in the same readme file). I assumed changing the control colors would be similar, but perhaps not...

I can try some experiments on my own, but it might be a few days before I can devote more time to it. :(

OK, I had a couple minute of free time during my lunch break. I did a quick sample using MUI and InstallOptions and it works for me. I'm not sure why you were having problems. (I'm using NSIS version 2.39 if that helps)

The sample is attached.


And here's an attached example of the same using nsDialogs. (I didn't quite get the dialog positions worked out, but I think it should at least give the general idea.)


awesome, it's working! i used !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ioA.ini" instead of !insertmacro MUI_INSTALLOPTIONS_SHOW, must've been it. thanks a lot!


one more question: what if i want to reset the background color to its initial state? i don't want to interfere with a user's system-white color-settings and set it to white. i assumed i can use transparent, but it turns black.

i'm using background colors to indicate missing or wrong information. hence i need to remove the colors if everything was done correctly!


for the record: i tried SetCtlColors $BU1_Directory "" "" and it solved my issue :)


i've created an example and posted in on the wiki