0

I want to insert a new page in the installation which contains two checkboxes named Client version and Server version. On clicking client version nothing special happens as of now. But if server version is selected then a browse option should come to select a folder (This is not a installation folder). I am finding some difficulties to do this. I have added two checkboxes, a text box and browse button. In the onchange of checkbox I make browse and textbox.

But now the problem is I want only one checkbox to be checked at a time.

When server version checked browse option should appear (which works now), but if it is unchecked again then that browse option should disappear (which does not work because I was not able to write code for that).

If I click Next on this page and then come back to same page using Back then all controls or checkbox I checked should be as it is. But now those browse options will disappear even if server version checkbox is selected (as I have not done proper coding for this also).

So please help me to do all these things. Also help me if there any other method to do the same

!define PRODUCT_NAME "My application"   
!define PRODUCT_VERSION "1.0"

Var Dialog
Var Text
Var Text_State
Var Checkbox
Var Checkbox1
Var Checkbox_State
Var Checkbox1_State
var /GLOBAL SOURCETEXT
var /global SOURCE
var /global BROWSESOURCE

!include "MUI.nsh"
!include nsDialogs.nsh

!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"

!insertmacro MUI_PAGE_WELCOME  
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"

Page custom InstallPageCreate checkinstdir
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "Setup.exe"
InstallDir "$PROGRAMFILES\My application"
ShowInstDetails show
ShowUnInstDetails show

Var InstallPageDialog
Var InstallPage.DirRequest
Var InstallPage.BrowseButton
Var mui.WelcomePage
Var mui.WelcomePage1
Var mui.WelcomePage.Image1
Var mui.WelcomePage.Title
Var mui.WelcomePage.Text
Var ImageHandle
Var mui.WelcomePage.Title.Font
Var LINK
Var LINK.Font
Var clickinstall
Var mui.WelcomePage.Image.Bitmap
var checked
var checked1
Var CheckBox.Font
var mui.WelcomePage1.Title1
var mui.WelcomePage.Title.Font1


Function InstallPageCreate
    nsDialogs::Create 1044
    Pop $mui.WelcomePage
    nsDialogs::SetRTL $(^RTL)
    SetCtlColors $mui.WelcomePage 0xffffff 0xffffff

    ${NSD_CreateLabel} 120u 70u 140u 14u "Choose the intallation method"
    Pop $clickinstall
    SetCtlColors $clickinstall "" "ffffff"  

    ${NSD_CreateCheckbox} 120u 90u 100% 10u "&Client version"
    Pop $CheckBox
    CreateFont $CheckBox.Font "$(^Font)" "08" "500"
    SetCtlColors $CheckBox "" "FFFFFF"
    SendMessage $CheckBox ${WM_SETFONT} $CheckBox.Font 0
    GetFunctionAddress $0 OnCheckbox1
    nsDialogs::OnClick $CheckBox $0

    ${NSD_CreateCheckbox} 120u 100u 100% 10u "&Server version"
    Pop $CheckBox1
    CreateFont $CheckBox.Font "$(^Font)" "08" "500"
    SetCtlColors $CheckBox1 "" "FFFFFF"
    SendMessage $CheckBox1 ${WM_SETFONT} $CheckBox.Font 0
    GetFunctionAddress $0 OnCheckbox2

    nsDialogs::OnClick $CheckBox1 $0

    ${If} $Checkbox_State == ${BST_CHECKED}
        ${NSD_Check} $Checkbox
    ${EndIf}

    ${If} $Checkbox1_State == ${BST_CHECKED}
        ${NSD_Check} $Checkbox1
    ${EndIf}

    nsDialogs::Show
    ${NSD_FreeImage} $mui.WelcomePage.Image.Bitmap
FunctionEnd


Function OnCheckbox2
    StrCpy $SOURCE "C:\"

    ${NSD_CreateText} 120u 120u 80u 12u "$SOURCE"
    pop $SOURCETEXT

    ${NSD_CreateBrowseButton} 280u 120u 35u 14u "Browse"
    Pop $InstallPage.BrowseButton

    ${NSD_OnClick} $InstallPage.BrowseButton Browsesource
FunctionEnd


Function OnCheckbox1
FunctionEnd


Function checkinstdir
    ${NSD_GetText} $Text $Text_State
    ${NSD_GetState} $Checkbox $Checkbox_State

    ${If} $Checkbox_State == ${BST_CHECKED}
        strcpy $checked 1
    ${else}
        strcpy $checked 0
    ${Endif}

    ${NSD_GetState} $Checkbox1 $Checkbox1_State

    ${If} $Checkbox1_State == ${BST_CHECKED}
        strcpy $checked1 1
    ${else}
        strcpy $checked1 0
    ${Endif}
FunctionEnd


Function Browsesource
    nsDialogs::SelectFolderDialog "Select Source Folder" "c:\"
    pop $SOURCE

    ${NSD_SetText} $SOURCETEXT $SOURCE
FunctionEnd


Section "MainSection" SEC01
SectionEnd


Section -Post
SectionEnd
4

0 回答 0