Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Adding a checkbox to the MUI_WELCOME page (http://forums.winamp.com/showthread.php?t=227262)

Jamyn 29th September 2005 20:59

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:

Quote:

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 :)

Jamyn 29th September 2005 21:36

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.

Jamyn 30th September 2005 22:05

Example
 
1 Attachment(s)
(Picture attached)

PHP Code:

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 littleshrink 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 :)

kichik 30th September 2005 22:17

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

Jamyn 30th September 2005 22:33

Thanks!
 
Thanks for the help sir! :)

Jamyn 2nd October 2005 06:43

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

Animaether 3rd October 2005 02:17

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.

Jamyn 4th October 2005 06:13

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.

kichik 4th October 2005 09:54

Quote:

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! :)


All times are GMT. The time now is 17:47.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.