WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Conditionally present Quick Launch checkbox
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
pauljlucas
Junior Member

Registered: Nov 2009
From: San Francisco

Conditionally present Quick Launch checkbox

Since Quick Launch icons apparently aren't used in Windows 7, I want my installer not to present the user with the Quick Launch checkbox on the Components page if the user is running Windows 7.

First, to determine whether the user is running Windows 7, I have:

code:
Function .onInit Var /GLOBAL WindowsVersion ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber StrCpy $R1 $R0 3 StrCmp $R1 '6.1' 0 +2 StrCpy $WindowsVersion "7" FunctionEnd


I'm using MUI2 and also have:

code:
!define MUI_COMPONENTSPAGE_NODESC !insertmacro MUI_PAGE_COMPONENTS ; ... [snip] ... LangString LS_QuickLaunchIconSecName ${LANG_ENGLISH} \ "Quick Launch icon" ; ... [snip] ... Section "$(LS_QuickLaunchIconSecName)" CreateShortCut "$QUICKLAUNCH\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" SectionEnd


However, it's not clear how to conditionally disable the Quick Launch checkbox (yet still leave the remaining components intact).

Also, as an aside, I wrote this stuff a while ago. In looking back, it's no longer clear to me how NSIS "knows" the above section is the section that specifies the Quick Launch checkbox. So, how does it "know?"

Thanks for any help.

Quick Link | Report this post to a moderator | IP: Logged

pauljlucas is offline Old Post 11-25-2009 07:34 PM
Click Here to See the Profile for pauljlucas Click here to Send pauljlucas a Private Message Find more posts by pauljlucas Add pauljlucas to your buddy list Edit/Delete Message Reply w/Quote
Anders
Major Dude

Registered: Jun 2002
From: N/A

don't read the registry to find the windows version, use winver.nsh

to disable/uncheck a section, the section needs an id, specify the id like so: section "display name" myId

then, somewhere _after_ that section in the script, you need to use a function that is called at runtime (.oninit,.onguiinit or the pre callback for the components page) and disable the section if needed using the helper macros in sections.nsh

__________________
IntOp $PostCount $PostCount + 1

Quick Link | Report this post to a moderator | IP: Logged

Anders is offline Old Post 11-25-2009 07:49 PM
Click Here to See the Profile for Anders Click here to Send Anders a Private Message Visit Anders's homepage! Find more posts by Anders Add Anders to your buddy list Edit/Delete Message Reply w/Quote
pauljlucas
Junior Member

Registered: Nov 2009
From: San Francisco

OK, I now have:

code:
Section "$(LS_QuickLaunchIconSecName)" S_QuickLaunch CreateShortCut "$QUICKLAUNCH\${APP_NAME}.lnk" "$INSTDIR\${APP_NAME}.exe" SectionEnd ; ... [snip] ... Function .onInit ${If} ${IsWin7} UnselectSection S_QuickLaunch ${Endif} FunctionEnd

When I run this on a machine running Windows 7, it still shows the Quick Launch checkbox. (Yes, I'm including the necessary files.)

Quick Link | Report this post to a moderator | IP: Logged

pauljlucas is offline Old Post 11-25-2009 10:35 PM
Click Here to See the Profile for pauljlucas Click here to Send pauljlucas a Private Message Find more posts by pauljlucas Add pauljlucas to your buddy list Edit/Delete Message Reply w/Quote
Anders
Major Dude

Registered: Jun 2002
From: N/A

section "name" id
...
UnselectSection ${id}

also, to _hide_ the item, you need to set its name to an empty string

__________________
IntOp $PostCount $PostCount + 1

Quick Link | Report this post to a moderator | IP: Logged

Anders is offline Old Post 11-25-2009 10:41 PM
Click Here to See the Profile for Anders Click here to Send Anders a Private Message Visit Anders's homepage! Find more posts by Anders Add Anders to your buddy list Edit/Delete Message Reply w/Quote
pauljlucas
Junior Member

Registered: Nov 2009
From: San Francisco

The:

code:
UnselectSection ${S_QuickLaunch}

by itself made no difference.

How do you set its name to an empty string?

Quick Link | Report this post to a moderator | IP: Logged

pauljlucas is offline Old Post 11-25-2009 10:50 PM
Click Here to See the Profile for pauljlucas Click here to Send pauljlucas a Private Message Find more posts by pauljlucas Add pauljlucas to your buddy list Edit/Delete Message Reply w/Quote
Anders
Major Dude

Registered: Jun 2002
From: N/A

by reading about sections in the helpfile

__________________
IntOp $PostCount $PostCount + 1

Quick Link | Report this post to a moderator | IP: Logged

Anders is offline Old Post 11-25-2009 11:05 PM
Click Here to See the Profile for Anders Click here to Send Anders a Private Message Visit Anders's homepage! Find more posts by Anders Add Anders to your buddy list Edit/Delete Message Reply w/Quote
pauljlucas
Junior Member

Registered: Nov 2009
From: San Francisco

I now have:

code:
Function .onInit ${If} ${IsWin7} UnselectSection ${S_QuickLaunch} SectionSetText ${S_QuickLaunch} "" ${EndIf} FunctionEnd

and there's still no change.

Quick Link | Report this post to a moderator | IP: Logged

pauljlucas is offline Old Post 11-25-2009 11:10 PM
Click Here to See the Profile for pauljlucas Click here to Send pauljlucas a Private Message Find more posts by pauljlucas Add pauljlucas to your buddy list Edit/Delete Message Reply w/Quote
Anders
Major Dude

Registered: Jun 2002
From: N/A

code:
!include WinVer.nsh !include Sections.nsh page components page instfiles Section foo bar SectionEnd Function .onInit ${If} 1 == 1 ;replace with OS test !insertmacro UnselectSection ${bar} SectionSetText ${bar} "" ${EndIf} FunctionEnd

__________________
IntOp $PostCount $PostCount + 1

Quick Link | Report this post to a moderator | IP: Logged

Anders is offline Old Post 11-25-2009 11:28 PM
Click Here to See the Profile for Anders Click here to Send Anders a Private Message Visit Anders's homepage! Find more posts by Anders Add Anders to your buddy list Edit/Delete Message Reply w/Quote
pauljlucas
Junior Member

Registered: Nov 2009
From: San Francisco

D'oh! I realized I wasn't editing the copy of the file that was being used to generate the installer, so of course the result was no different.

Anyway, it works now that I'm editing the correct file. Thanks for your patience.

Quick Link | Report this post to a moderator | IP: Logged

pauljlucas is offline Old Post 11-25-2009 11:48 PM
Click Here to See the Profile for pauljlucas Click here to Send pauljlucas a Private Message Find more posts by pauljlucas Add pauljlucas to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 09:19 PM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > Conditionally present Quick Launch checkbox
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON