3

enter image description here

I want that if none of the RadioButtons are selected , then ,when the Next button is pressed, then it should give an alert that PLEASE CHOSE ATLEAST ONE ITEM, and it should not go to the next Dialog.

Also, I want that if the user selects the option : UPDATE EXISTING SOFTWARE, then only some files are copied, and if the other radiobutton is selected , then all files are copied,

Is this possible using sections or functions have to be used? can i call a Section, like if RadioButton 1 is chosen, then SECTION CREATEALLFILES is called, else SECTION CREATEONLYTWOFILES is called?

According to me, i think i want the code to HOW TO HOLD THE ids of these two RadioButtons and use them accordingly , to call different sections or functions. What would be the code? Please help?

Also, after pressing NEXT on this page, the next dialog will come as in image below: i want to show a LABEL , whether DEMO is done, or UPDATE is running, for this i will add a Label using Resource Hacker, but how to display that Label and hide it according to user choice of RadioButton enter image description here

4

1 回答 1

2

您可以选择/取消选择部分或将逻辑放在一个部分中,此示例同时执行以下操作:

!include nsDialogs.nsh
!include Sections.nsh

var InstallType

Section 
#Install common files...
${If} $InstallType == DEMO
    #Do demo specific stuff
${Else}
    #Do update specific stuff
${EndIf}
SectionEnd

Section "" SEC_DEMO
#Install demo..
SectionEnd

Section "" SEC_UPDATE
#Do update..
SectionEnd

Page custom InstTypePageCreate InstTypePageLeave

Function InstTypePageCreate
nsDialogs::Create 1018
pop $0
${NSD_CreateRadioButton} 0 50u 100% 10u "Demo"
pop $1
${IfThen} $InstallType == DEMO ${|} ${NSD_Check} $1 ${|}
${NSD_CreateRadioButton} 0 70u 100% 10u "Update"
pop $2
${IfThen} $InstallType == UPDATE ${|} ${NSD_Check} $2 ${|}
nsDialogs::Show
FunctionEnd

Function InstTypePageLeave
${NSD_GetState} $1 $0
${If} $0 = ${BST_CHECKED}
    StrCpy $InstallType DEMO
    !insertmacro UnselectSection ${SEC_UPDATE}
    !insertmacro SelectSection ${SEC_DEMO}
${Else}
    ${NSD_GetState} $2 $0
    ${If} $0 = ${BST_CHECKED}
        StrCpy $InstallType UPDATE
        !insertmacro UnselectSection ${SEC_DEMO}
        !insertmacro SelectSection ${SEC_UPDATE}
    ${Else}
        MessageBox MB_ICONSTOP "You must select something!"
        Abort
    ${EndIf}
${EndIf}
FunctionEnd

要设置下一页上的文本,只需${NSD_SetText} $hwndYourLabel "Text"在测试 $InstallType 的 if 块中使用和 ShowWindow(此代码需要在该页面的显示函数回调 (MUI_PAGE_CUSTOMFUNCTION_SHOW) 中)

于 2011-04-28T10:47:55.933 回答