Old 14th August 2005, 23:51   #1
Ahmad123
Guest
 
Posts: n/a
adding 3rd checkbox

how do i add a 3rd checkbox to the finish page?

so far i have this

code:
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Run Age of Empires Expansion"
!define MUI_FINISHPAGE_RUN_FUNCTION "runfile"
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION "scdesktop"

Function "runfile"
Exec "$INSTDIR\EMPIRESX.EXE"
FunctionEnd

Function "scdesktop"
CreateShortCut "$DESKTOP\Age of Empires Expansion.lnk" "$INSTDIR\EMPIRESX.EXE"
FunctionEnd

  Reply With Quote
Old 15th August 2005, 02:36   #2
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
You have to change some functions related to the finish page. Put the code below before inserting the macro MUI_PAGE_FINISH:

code:

!define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT InitFinishPage
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowFinishPage
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveFinishPage

The first define is the secret behind the checkbox insertion. "InitFinishPage" is the function to be called when the InstallOptions INI file for the page is written.

Just one more piece of information: The INI file for the page is called "iospecial.ini" and it's located in the $PLUGINSDIR. Also, this page contains 5 controls (with all the options you specified), so all you need to do in this function is:

code:

Function InitFinishPage
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Settings" "NumFields" "6"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Type" "CheckBox"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Left" "120"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Right" "315"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Top" "160"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Right" "170"
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "State" "0"
;line above: Initial state of the control: 0=Unchecked, 1=Checked
FunctionEnd

There are still things missing. There is still no repainting of the background of the control to the color white. This you'll do in the "ShowFinishPage" of the page:

code:

Function ShowFinishPage
GetDlgItem $MUI_TEMP1 $MUI_HWND 1205 ;ID for the 6th InstallOptions control
SetCtlColors $MUI_TEMP1 "" "${MUI_BGCOLOR}"
FunctionEnd

The "${MUI_BGCOLOR}" define is the background color of the page, which will be set to white by default. The $MUI_TEMP1 variable is a Modern UI temporary variable, which can be changed if you want to. Also, the $MUI_HWND variable holds the dialog handle for the InstallOptions page, needed for the GetDlgItem to detect the item and paint the background.

One last thing: You need to verify the state of the CheckBox before going out of the page. To do that, use the "LeaveFinishPage" function:

code:

Function LeaveFinishPage
!insertmacro MUI_INSTALLOPTIONS_READ $MUI_TEMP1 "ioSpecial.ini" "Field 6" "State"
StrCmp $MUI_TEMP1 1 Checked Unchecked
Checked:
;Put your code for when the checkbox is checked here
Goto end
Unchecked:
;Put your code for when the checkbox is unchecked here
end:
FunctionEnd

Put the codes to execute when the checkbox is unchecked or checked and all done!

You may have noted the use of !insertmacro MUI_INSTALLOPTIONS_WRITE and !insertmacro MUI_INSTALLOPTIONS_READ. Those are replacements for WriteINIFile and ReadINIFile respectively. The difference is that the file "iospecial.ini" is in $PLUGINSDIR, and these macros write/read only to/from files inside $PLUGINSDIR, so they are made for this occasion.

I didn't test those codes. If they don't work, at least I showed my point...

(EDIT: Just for curiosity, what did you create for Age of Empires? Or are you trying to put back old utilities for it? Hmmm...)

My Wiki Pages

Working now on:
New projects. (language: any)

Last edited by deguix; 15th August 2005 at 03:06.
deguix is offline   Reply With Quote
Old 15th August 2005, 05:05   #3
Ahmad123
Guest
 
Posts: n/a
Hi, thanks for the detailed answer, although I'm quite new at this (i've only had nsis for a couple of days). I received the following error

code:
unknown variable/constant "MUI_HWND" detected, ignoring (D:\My Documents\aoex.nsi:79)


Also, where would I place the text for checkbox? Do I changed "Field 6"?

Many thanks.
  Reply With Quote
Old 15th August 2005, 09:15   #4
Ahmad123
Guest
 
Posts: n/a
I do believe that his piece of code is the only bit not working:

code:
Function ShowFinishPage
GetDlgItem $MUI_TEMP1 $MUI_HWND 1205 ;ID for the 6th InstallOptions control
SetCtlColors $MUI_TEMP1 "" "${MUI_BGCOLOR}"
FunctionEnd



If i set the state manually in the script to 1 it will perform the function I request once I've clicked Finish. It just doesn't seem to be drawing the checkbox onto the page.

Error

code:
unknown variable/constant "MUI_HWND" detected, ignoring (D:\My Documents\aoex.nsi:79)


Quote:
(EDIT: Just for curiosity, what did you create for Age of Empires? Or are you trying to put back old utilities for it? Hmmm...)
3rd party apps like CTY Editor, AI Editor, extra campaigns etc
  Reply With Quote
Old 15th August 2005, 11:27   #5
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
Quote:
Also, where would I place the text for checkbox? Do I changed "Field 6"?
Whoops, just add this line below to the "InitFinishPage":
code:

!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Text" "Checkbox Text" ;Change this for the text desired

Now for the second error, that wasn't supposed to happen. It is mentioned in the Modern UI documentation that this variable is available in the Show function for this page. Try updating your NSIS to 2.08 if you have an older version.

My Wiki Pages

Working now on:
New projects. (language: any)

Last edited by deguix; 15th August 2005 at 11:55.
deguix is offline   Reply With Quote
Old 15th August 2005, 12:07   #6
Ahmad123
Guest
 
Posts: n/a
Quote:
Originally posted by deguix
Whoops, just add this line below to the "InitFinishPage":
code:

!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "Field 6" "Text" "Checkbox Text" ;Change this for the text desired


Yep, I figured that one out :P

Now for the second error, that wasn't supposed to happen. It is mentioned in the Modern UI documentation that this variable is available in the Show function for this page. Try updating your NSIS to 2.08 if you have an older version.
Yes, I have version 2.08 but the error still exists

Also, when checking the ioSpecial.ini in the temp folder at runtime, the NumFields value under [Settings] is still set to 5 and not 6
  Reply With Quote
Old 15th August 2005, 14:44   #7
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Did you put the functions below the Modern UI settings? Please attach a script that reproduces the problem.
Joost Verburg is offline   Reply With Quote
Old 15th August 2005, 15:31   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Looks like it is above the page macros.

-Stu
Afrow UK is offline   Reply With Quote
Old 15th August 2005, 15:31   #9
Ahmad1234
Guest
 
Posts: n/a
Ok I solved the error, I didn't have a WELCOME page, so I had to insert one
code:
!insertmacro MUI_PAGE_WELCOME
is there any way around that?

Even now that there are no errors, the 3rd checkbox is still not showing up.. I have attached a sample script

Thanks
Attached Files
File Type: zip testapp.zip (2.5 KB, 159 views)
  Reply With Quote
Old 15th August 2005, 15:35   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Move:

!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

Above all the functions and just below:

!define MUI_FINISHPAGE_SHOWREADME_FUNCTION "runfile2"

Edit: and you want this before it too:
!define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT InitFinishPage
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ShowFinishPage
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveFinishPage

-Stu
Afrow UK is offline   Reply With Quote
Old 15th August 2005, 20:17   #11
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
The functions have to be after the !insertmacro MUI_PAGE_FINISH because the $MUI_HWND variable is not yet defined before it.

To fix the checkbox not showing correctly, remove the line:

code:

!define MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT InitFinishPage



Add this line in its place:

code:
!define MUI_PAGE_CUSTOMFUNCTION_PRE PreFinishPage


And rename the function "InitFinishPage" to "PreFinishPage".

The difference between those 2 defines is that the MUI_WELCOMEFINISHPAGE_CUSTOMFUNCTION_INIT specifies the function which is executed before everything, so future !insertmacro MUI_INSTALLOPTIONS_WRITE macros will overwrite the settings you put, and the MUI_PAGE_CUSTOMFUNCTION_PRE is after the page created the INI file structure.

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 15th August 2005, 22:12   #12
Ahmad1234
Guest
 
Posts: n/a
I'm sure that I've done everything you said above, but the checkbox still is not appearing.

Could you please attach a working, modified version of my testapp.nsi

Thanks.
  Reply With Quote
Old 15th August 2005, 23:00   #13
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
Ah, it isn't working now because you put a bigger value in the "Top" INI value of the control than the "Bottom" value. The point (0,0) of a dialog is in the top-left corner of it. My first code about the dimensions would make it appear. To make the checkbox placement more natural with the other checkboxes, put the top value as "130" and bottom value as "140".

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 15th August 2005, 23:40   #14
Ahmad1234
Guest
 
Posts: n/a
Thank you! It is now working..

Sorry for being so n00bish :P, thanks for the great support, much appreciated! especially deguix
  Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump