Old 2nd December 2013, 23:06   #1
Jayme65
Junior Member
 
Join Date: May 2013
Posts: 9
Checkbox for custom installation

Hi,

My application installs a few files in the %APPDATA% folder...but I would like to add a checkbox to give the user the option to install those files in my application folder (for people willing to do a "portable" installation.

How should I please proceed to implement the checkbox and set the conditions (if not checked install data files in appdata. If checked install those files in the app folder)

Thanks very much for your help!
Jayme65 is offline   Reply With Quote
Old 2nd December 2013, 23:09   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
You could use a section and let the user toggle it on the components page or you can create a custom page with nsDialogs...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 2nd December 2013, 23:32   #3
Jayme65
Junior Member
 
Join Date: May 2013
Posts: 9
Thanks for your quick reply!

Well unfortunately I don't know NSIS very well..so I'll take time to understand and implement what you propose me ;-)

How do I then set the files to be installed in a folder or another, based on the checkbox condition? (this being done on the next page)

Thanks!!
Jayme65 is offline   Reply With Quote
Old 2nd December 2013, 23:53   #4
Koopa
16-Bit Moderator
 
Koopa's Avatar
 
Join Date: Apr 2004
Posts: 4,341
You can do a custom page, like Anders said, in a callback function, you can define, what happens if the box is checked or what happens if the box is unchecked.

code:

Page custom MyPage CheckMyPage

Function MyPage

Var /GLOBAL MyDialog
Var /GLOBAL MyCheckbox

nsDialogs::Create 1018
Pop $MyDialog

${If} $MyDialog == error
Abort
${EndIf}

${NSD_CreateGroupBox} 0u 0u 300u 140u "Groupbox"
${NSD_CreateCheckBox} 5u 5u 220u 12u "My Checkbox Name"
Pop $MyCheckbox
SetCtlColors $MyCheckbox "0x000000" "transparent"
${NSD_SetState} $MyCheckbox ${BST_CHECKED}

nsDialogs::Show

FunctionEnd

Function CheckMyPage
Var /GLOBAL MyCheckbox_State

${NSD_GetState} $MyCheckbox $MyCheckbox_State
${If} $MyCheckbox_State = ${BST_CHECKED}
SetOutPath "C:\Blah"
File "text.txt"
${Else}
SetOutPath "$APPDATA\Blah"
File "text.txt"
${EndIf}

FunctionEnd


Note that you must call some specific things, like:
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "LogicLib.nsh"

As I haven't seen your script, I don't know what you are already calling and what not.
Koopa is offline   Reply With Quote
Old 2nd December 2013, 23:55   #5
Jayme65
Junior Member
 
Join Date: May 2013
Posts: 9
Koopa,

Thanks so much for taking time to give me code line to study!
That's really appreciated!!
I now go and study that ;-) Thanks
Jayme65 is offline   Reply With Quote
Old 3rd December 2013, 00:08   #6
Koopa
16-Bit Moderator
 
Koopa's Avatar
 
Join Date: Apr 2004
Posts: 4,341
Though, it's nothing more than raw example code. without seeing your script it's hard to help. And even using my code example requires some knowledge. I highly recommend, that you read the NSIS documentation, wiki etc.
Koopa is offline   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