NSIS optional custom pages

soundlarp

I want to create a checkbox in NSIS at the end of the installation process, when checked, it will lead the user to a custom page that has a bunch of radioboxes that lead the user to another custom page (depending on the choice) and so on.

I know how to create a custom page using nsDialogs, but I can't figure out the logic behind multiple optional custom pages. Any help is appreciated.

Alternatively, is there a way to create multiple checkbox/radiobox groups that are disabled by default (except the first one) and only activated when the user selects a box in a group before it?

Anders

Pages are skipped by calling Abort in the page Pre-callback. Then all you have to do is keep track of which page you want to show and which you want to skip:

!include nsDialogs.nsh
!include LogicLib.nsh

Section "Do custom page thing" SID_DOCUSTOMPAGES
SectionEnd

Page Components
Page InstFiles
Page Custom Cust1Pre Cust2Next
Page Custom CustAPre
Page Custom CustBPre

Var WantedPage

Function Cust1Pre
${IfNot} ${SectionIsSelected} ${SID_DOCUSTOMPAGES}
    StrCpy $WantedPage ""
    Abort
${EndIf}
nsDialogs::Create 1018
Pop $0
${NSD_CreateRadioButton} 0 30u 100% 10u "Page A"
Pop $1
${NSD_Check} $1
${NSD_CreateRadioButton} 0 40u 100% 10u "Page B"
Pop $2
nsDialogs::Show
FunctionEnd

Function Cust2Next
${NSD_GetState} $1 $0
${If} $0 <> ${BST_UNCHECKED}
    StrCpy $WantedPage A
${Else}
    StrCpy $WantedPage B
${EndIf}
FunctionEnd

Function CustAPre
${IfNotThen} $WantedPage == A ${|} Abort ${|}
GetDlgItem $0 $hWndParent 1
SendMessage $0 ${WM_SETTEXT} "" "STR:$(^CloseBtn)" ; Change button text since page B is skipped and we are now the last page
nsDialogs::Create 1018
Pop $0
${NSD_CreateButton} 0 30u 100% 10u "Page A"
Pop $0
nsDialogs::Show
FunctionEnd

Function CustBPre
${IfNotThen} $WantedPage == B ${|} Abort ${|}
nsDialogs::Create 1018
Pop $0
${NSD_CreateButton} 0 30u 100% 10u "Page B"
Pop $0
nsDialogs::Show
FunctionEnd

You can get rid of the WM_SETTEXT workaround by having a single page that is "A" or "B":

!include nsDialogs.nsh
!include LogicLib.nsh

Section "Do custom page thing" SID_DOCUSTOMPAGES
SectionEnd

Page Components
Page InstFiles
Page Custom Cust1Pre Cust2Next
Page Custom CustAOrBPre

Var WantedPage

Function Cust1Pre
${IfNot} ${SectionIsSelected} ${SID_DOCUSTOMPAGES}
    StrCpy $WantedPage ""
    Abort
${EndIf}
nsDialogs::Create 1018
Pop $0
${NSD_CreateRadioButton} 0 30u 100% 10u "Page A"
Pop $1
${NSD_Check} $1
${NSD_CreateRadioButton} 0 40u 100% 10u "Page B"
Pop $2
nsDialogs::Show
FunctionEnd

Function Cust2Next
${NSD_GetState} $1 $0
${If} $0 <> ${BST_UNCHECKED}
    StrCpy $WantedPage A
${Else}
    StrCpy $WantedPage B
${EndIf}
FunctionEnd

Function CustAPre
nsDialogs::Create 1018
Pop $0
${NSD_CreateButton} 0 30u 100% 10u "Page A"
Pop $0
nsDialogs::Show
FunctionEnd

Function CustBPre
nsDialogs::Create 1018
Pop $0
${NSD_CreateButton} 0 30u 100% 10u "Page B"
Pop $0
nsDialogs::Show
FunctionEnd

Function CustAOrBPre
${If} $WantedPage == A
    Call CustAPre
${Else}
    Call CustBPre
${EndIf}
FunctionEnd

Having just a single page with disabled options is of course better:

!include nsDialogs.nsh
!include LogicLib.nsh

Page InstFiles
Page Custom CustPre

Function CustPre
nsDialogs::Create 1018
Pop $0

${NSD_CreateCheckBox} 10 30u 100% 10u "Enable other stuff"
Pop $0
${NSD_OnClick} $0 OnCheckChange

${NSD_CreateRadioButton} 10 50u 100% 10u "Foo"
Pop $1
${NSD_AddStyle} $1 ${WS_GROUP}
${NSD_Check} $1
${NSD_CreateRadioButton} 10 70u 100% 10u "Bar"
Pop $2
${NSD_RemoveStyle} $2 ${WS_TABSTOP}

Push $0
Call OnCheckChange ; Enforce state
nsDialogs::Show
FunctionEnd

!macro SetRadiosEnabled state
EnableWindow $1 ${state}
EnableWindow $2 ${state}
!macroend
Function OnCheckChange
Pop $0
${NSD_GetState} $0 $0
${If} $0 <> ${BST_UNCHECKED}
    !insertmacro SetRadiosEnabled 1
${Else}
    !insertmacro SetRadiosEnabled 0
${EndIf}
FunctionEnd

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Custom default struct as optional parameter

分類Dev

Github pages with custom domain names

分類Dev

Throw a custom exception in optional in Java8

分類Dev

Pass Optional Event Handler to Custom Button

分類Dev

Store custom data type in @AppStorage with optional initializer?

分類Dev

Wordpress custom menu displayng all pages

分類Dev

Display a custom taxonomy in Woocommerce single product pages

分類Dev

Blazor Security - Razor Pages custom authentication/security

分類Dev

Custom JSON serializer for optional property with System.Text.Json

分類Dev

Add a custom field value below product title in WooCommerce archives pages

分類Dev

Add custom meta data to admin order edit pages in Woocommerce 3

分類Dev

Blank webpage when using GitHub pages with custom Google domain

分類Dev

Add class to WooCommerce pages via custom checkbox in WooCommerce product settings

分類Dev

Drupal module development, custom database tables, pages for managing those data

分類Dev

NSIS!finalize catch error

分類Dev

Custom Error Pages using ExecuteURL in .NET ASPX application not working (Redirects work fine)

分類Dev

NSIS複数のif条件

分類Dev

Getting PATH variable in NSIS script

分類Dev

Getting a path for each component in NSIS

分類Dev

NSIS' uninstaller works very fast

分類Dev

@PostFilter on Optional

分類Dev

Answering a user prompt from within NSIS installer

分類Dev

Can NSIS DumpLog be used with 64 bit version?

分類Dev

NSIS Get file version of EXE that is UPX Compressed

分類Dev

How to make own language file in NSIS?

分類Dev

Optional binding with try? and as? still produces an optional type

分類Dev

NSIS:NSIS2およびNSIS3と互換性のあるスクリプト

分類Dev

OptionalIntとOptional <Integer>

分類Dev

Optional generic type

Related 関連記事

  1. 1

    Custom default struct as optional parameter

  2. 2

    Github pages with custom domain names

  3. 3

    Throw a custom exception in optional in Java8

  4. 4

    Pass Optional Event Handler to Custom Button

  5. 5

    Store custom data type in @AppStorage with optional initializer?

  6. 6

    Wordpress custom menu displayng all pages

  7. 7

    Display a custom taxonomy in Woocommerce single product pages

  8. 8

    Blazor Security - Razor Pages custom authentication/security

  9. 9

    Custom JSON serializer for optional property with System.Text.Json

  10. 10

    Add a custom field value below product title in WooCommerce archives pages

  11. 11

    Add custom meta data to admin order edit pages in Woocommerce 3

  12. 12

    Blank webpage when using GitHub pages with custom Google domain

  13. 13

    Add class to WooCommerce pages via custom checkbox in WooCommerce product settings

  14. 14

    Drupal module development, custom database tables, pages for managing those data

  15. 15

    NSIS!finalize catch error

  16. 16

    Custom Error Pages using ExecuteURL in .NET ASPX application not working (Redirects work fine)

  17. 17

    NSIS複数のif条件

  18. 18

    Getting PATH variable in NSIS script

  19. 19

    Getting a path for each component in NSIS

  20. 20

    NSIS' uninstaller works very fast

  21. 21

    @PostFilter on Optional

  22. 22

    Answering a user prompt from within NSIS installer

  23. 23

    Can NSIS DumpLog be used with 64 bit version?

  24. 24

    NSIS Get file version of EXE that is UPX Compressed

  25. 25

    How to make own language file in NSIS?

  26. 26

    Optional binding with try? and as? still produces an optional type

  27. 27

    NSIS:NSIS2およびNSIS3と互換性のあるスクリプト

  28. 28

    OptionalIntとOptional <Integer>

  29. 29

    Optional generic type

ホットタグ

アーカイブ