Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 15th May 2008, 21:34   #1
tmxk
Junior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 32
Post How to pop up a page if a section in component page is selected?

Hi all,

I am new to NSIS.
Can anybody tell me how to pop up a page if a section in component page is selected? This page should not show up in the main script, otherwise it always pops up no mater the related section is selected or not.
Thanks in advance.

Jue
tmxk is offline   Reply With Quote
Old 16th May 2008, 06:11   #2
jiake
Senior Member
 
jiake's Avatar
 
Join Date: Oct 2007
Location: Xi'an, China
Posts: 194
You can see the example "makensis.nsi"

An NSIS fan from China, my name is Jia Ke (pinyin).
Email: jiake@vip.qq.com
Messenger: jiake@live.in
QQ (Chinese IM): 550771955
jiake is offline   Reply With Quote
Old 16th May 2008, 06:47   #3
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
code:
outfile test.exe
ShowInstDetails show
InstallDir "$PROGRAMFILES\My Application"

!include logiclib.nsh

page components
page directory pre_func
page instfiles

Section "Main Application" sec1
detailprint "installing Main pplication"
SectionEnd

Section /o "!When checked enables the directory page" sec2
detailprint "Installing..."
Sectionend

Function pre_func
SectionGetFlags ${sec2} $R0
Intop $R1 $R0 | 1
${Unless} $R0 = $R1
Abort
${EndUnless}
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 16th May 2008, 11:25   #4
tmxk
Junior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 32
Thank both you experts. It works.
tmxk is offline   Reply With Quote
Old 16th May 2008, 12:18   #5
tmxk
Junior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 32
Hi, can I have another question?

I have a custom page on which there are 2 Radiobuttons, after the selection of the 2 Radiobuttons, a component page shows up, some of the sections will be disabled or enabled based on the Radiobutton selection. How can I set the sections?
From my understanding, there is one way, such as "SectionIn RO", but it is only for compile time but runtime.
And there is another way to do it for runtime, "SetSectionFlag ${SEC_NAM} ${SF_RO}", but I tried to set it either in RadioButton page function (PageLeave) or in the relative section.
Can you experts help?
Thanks in advance.
tmxk is offline   Reply With Quote
Old 16th May 2008, 15:43   #6
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
2 examples, first is to keep sections in tact when back button is pressed and second simply disables back button.
code:
!define CUST_INI "$PLUGINSDIR\custom.ini"
!include Logiclib.nsh
!include Sections.nsh

!define SEC1_TEXT "Section One"
!define SEC2_TEXT "Section Two"
!define SEC3_TEXT "Section Three"

outfile "test.exe"
showinstdetails show
Installdir "$PROGRAMFILES\My App"

page custom CreateCustom
page components func_pre
page directory
page instfiles

section "${SEC1_TEXT}" sec1
detailprint "section 1 selected"
sectionend

section "${SEC2_TEXT}" sec2
detailprint "section 2 selected"
sectionend

section "${SEC3_TEXT}" sec3
detailprint "section 3 selected"
sectionend

Function .onInit
InitPluginsDir

WriteINIStr "${CUST_INI}" "Settings" "NumFields" "3"

WriteINIStr "${CUST_INI}" "field 1" "type" "radiobutton"
WriteINIStr "${CUST_INI}" "field 1" "left" "30"
WriteINIStr "${CUST_INI}" "field 1" "right" "-30"
WriteINIStr "${CUST_INI}" "field 1" "top" "40"
WriteINIStr "${CUST_INI}" "field 1" "bottom" "52"
WriteINIStr "${CUST_INI}" "field 1" "Text" "Unselect and hide section 1"
WriteINIStr "${CUST_INI}" "field 1" "state" "1"
WriteINIStr "${CUST_INI}" "field 1" "flags" "GROUP"

WriteINIStr "${CUST_INI}" "field 2" "type" "radiobutton"
WriteINIStr "${CUST_INI}" "field 2" "left" "30"
WriteINIStr "${CUST_INI}" "field 2" "right" "-30"
WriteINIStr "${CUST_INI}" "field 2" "top" "60"
WriteINIStr "${CUST_INI}" "field 2" "bottom" "72"
WriteINIStr "${CUST_INI}" "field 2" "Text" "Unselect and hide section 2"
WriteINIStr "${CUST_INI}" "field 2" "state" "0"

WriteINIStr "${CUST_INI}" "field 3" "type" "radiobutton"
WriteINIStr "${CUST_INI}" "field 3" "left" "30"
WriteINIStr "${CUST_INI}" "field 3" "right" "-30"
WriteINIStr "${CUST_INI}" "field 3" "top" "80"
WriteINIStr "${CUST_INI}" "field 3" "bottom" "92"
WriteINIStr "${CUST_INI}" "field 3" "Text" "Unselect and hide section 3"
WriteINIStr "${CUST_INI}" "field 3" "state" "0"
FunctionEnd

Function CreateCustom
InstallOptions::Dialog "${CUST_INI}"
pop $0
FunctionEnd

Function func_pre
ReadINIStr $0 "${CUST_INI}" "field 1" "state"
${If} $0 = 1
!insertmacro UnselectSection ${sec1}
SectionSetText ${sec1} ""
!insertmacro SelectSection ${sec2}
SectionSetText ${sec2} "${SEC2_TEXT}"
!insertmacro SelectSection ${sec3}
SectionSetText ${sec3} "${SEC3_TEXT}"
${ElseIf} $0 = 0
ReadINIStr $1 "${CUST_INI}" "field 2" "state"
${AndIf} $1 = 1
!insertmacro UnselectSection ${sec2}
SectionSetText ${sec2} ""
!insertmacro SelectSection ${sec1}
SectionSetText ${sec1} "${SEC1_TEXT}"
!insertmacro SelectSection ${sec3}
SectionSetText ${sec3} "${SEC3_TEXT}"
${Else}
!insertmacro UnselectSection ${sec3}
SectionSetText ${sec3} ""
!insertmacro SelectSection ${sec2}
SectionSetText ${sec2} "${SEC2_TEXT}"
!insertmacro SelectSection ${sec1}
SectionSetText ${sec1} "${SEC1_TEXT}"
${EndIf}
FunctionEnd

/*
Function func_pre
GetDlgItem $R0 $HWNDPARENT 3
EnableWindow $R0 0

ReadINIStr $0 "${CUST_INI}" "field 1" "state"
${If} $0 = 1
!insertmacro UnselectSection ${sec1}
SectionSetText ${sec1} ""
${ElseIf} $0 = 0
ReadINIStr $1 "${CUST_INI}" "field 2" "state"
${AndIf} $1 = 1
!insertmacro UnselectSection ${sec2}
SectionSetText ${sec2} ""
${Else}
!insertmacro UnselectSection ${sec3}
SectionSetText ${sec3} ""
${EndIf}
FunctionEnd


Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 16th May 2008, 19:02   #7
tmxk
Junior Member
 
Join Date: Apr 2008
Location: Canada
Posts: 32
Thank you very much, Red Wine. It works.

Cheers!
tmxk is offline   Reply With Quote
Reply
Go Back   Winamp 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