Archive: Adding a checkbox to the MUI_WELCOME page


Adding a checkbox to the MUI_WELCOME page
  Hi all,

I am curious if anyone is aware of a way to add one component to a MUI page (specifically the MUI_WELCOME page). Basically, I want to add one checkbox at the bottom of the welcome page that says "Check online for updates". I could of course write a custom page just for that one checkbox, but I think it'd be cleaner to integrate it into the existing MUI welcome page.

I saw the following in the manual, and I will be testing out some ideas in a few minutes:

MUI_WELCOMEFINISHPAGE_INI ini_file
InstallOptions INI file for the Welcome page and the Finish page.
Default: ${NSISDIR}\Contrib\Modern UI\ioSpecial.ini
But I don't want the "Check for updates" to show up on the finish page, just the welcome page. Well, if anyone has expertise in something like this, a basic shove in the right direction would be appreciated. Thanks :)

I'm guessing the easiest way to do this would be to add a PRE and LEAVE function to the MUI_WELCOME page, with the PRE function adding the checkbox to the MUI_WELCOME InstallOptions file, and the LEAVE function editing it back out? Hmmm. I'll have to look at it when I get home.


Example
  (Picture attached)

Function .onInit

InitPluginsDir
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioSpecial.ini"
>FunctionEnd

>...

Function PageWelcomeUpdateCheckbox
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Settings" "NumFields" "4"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Type" "Checkbox"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Left" "120"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Top" "170"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Right" "250"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Bottom" "180"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Text" "Check for program updates?"
; Bug?: The following line changes the checkbox to the right side (TRANSPARENT is invalid?)
; WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Flags" "NOTIFY|TRANSPARENT"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "Flags" "NOTIFY"
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 4" "State" "1"
; Field 3 overlaps the checkbox a little; shrink it.
WriteINIStr "$PLUGINSDIR\ioSpecial.ini" "Field 3" "Bottom" "169"
>FunctionEnd

>...

!define MUI_PAGE_CUSTOMFUNCTION_PRE "PageWelcomeUpdateCheckbox" ; Add update checkbox
!insertmacro MUI_PAGE_WELCOME

>...
(I need to write the exit function for MUI_WELCOME to work with the checkbox, but that's besides the point)

So far, things seem fine, with one caveat: The text with the checkbox does not have the same white background as the rest of the welcome page. Example picture attached.

Do I need to redraw the screen somehow? Is there a way to tell NSIS to use the same background for the checkbox as the rest of the welcome page? Any pointers would be greatly appreciated. I just have never tried to add additional components to an existing MUI page, so maybe I am missing something obvious. Anyway... any help or pointers would be greatly appreciated :)

Use SetCtlColors on the checkbox. Take a look at Contrib\Modern UI\System.nsh, it's done there a lot.


Thanks!
  Thanks for the help sir! :)


Hmm. Well, I ran into a brick wall with one of two things (I've never tried to modify a built in MUI page before).

1) Maybe I am modifying the page too early, and it's being redone by the actual MUI_WELCOMEPAGE macro. I am inserting the PRE page right before MUI_WELCOMEPAGE though.

2) I am not getting the right "hwnd" or handle for the checkbox. I'm not sure how to figure out what the handle is. I know when I use InstallOptions, the correct item is "1200 + <label> -1." But I don't think that applies to built in MUI pages. So item #4 in the inSpecial.ini file.. hmm, well, 1203 does not seem to be doing the trick (the background of the checkbox is not white.

So for now, I have been unsuccessful. I am going to just insert another custom page right after the welcome page until I can figure this out :P Thanks for the help all.

-J


You could always use WinSpy (google it) to get the control's ID (near the bottom, in HEX, convert to DEC). Really useful little tool, that.


Thanks all, for the help. I now have it working as intended. I will do a writeup describing some of the mistakes I made, and the proper way to do this, and submit it to the Wiki or something similar.


Originally posted by Jamyn
I will do a writeup describing some of the mistakes I made, and the proper way to do this, and submit it to the Wiki or something similar.
Great, thanks! :)