2014-07-04 90 views
0

我已經使用NSIS創建了一個安裝程序。在那我已經包括2個單選按鈕。每當用戶選擇任何一個單選按鈕,它立即開始執行,但我想在選擇一個單選按鈕執行後,應該只在用戶按下自定義按鈕後開始執行下一步。使用單選按鈕,然後按nsis中的自定義按鈕

那麼如何在我的腳本中添加按鈕(說下一個)以及如何連接我的單選按鈕選擇呢?

部分代碼片段如下:

Function mode_selection 

    nsDialogs::Create 1018 
    Pop $dialog 
    ${NSD_CreateLabel} 0 10 75% 20u "Choose your preference....." 
    Pop $0 

    ${NSD_CreateRadioButton} 20 60 100% 25u "Execution Mode" 
    Pop $hwnd 
    ${NSD_AddStyle} $hwnd ${WS_GROUP} 
    ${NSD_OnClick} $hwnd exec_mode 

    ${NSD_CreateRadioButton} 20 90 100% 25u "Debug Mode " 
    Pop $hwnd 
    ${NSD_OnClick} $hwnd debug_mode 


nsDialogs::Show 

FunctionEnd 

Function exec_mode 

    ;some code 

FunctionEnd 
Function debug_mode 

    ;some code 

FunctionEnd 

回答

0
!include nsDialogs.nsh 
!include LogicLib.nsh 
Page custom mode_selection 

var hwndExecModeRadio 

Function mode_selection 
nsDialogs::Create 1018 
Pop $0 
${NSD_CreateLabel} 0 10 75% 20u "Choose your preference....." 
Pop $0 

${NSD_CreateRadioButton} 20 60 80% 25u "Execution Mode" 
Pop $hwndExecModeRadio 
${NSD_AddStyle} $hwndExecModeRadio ${WS_GROUP} 

${NSD_CreateRadioButton} 20 90 80% 25u "Debug Mode " 
Pop $0 

${NSD_CreateButton} 20 150 -40 14u "Do it" 
Pop $0 
${NSD_OnClick} $0 perform_mode 

nsDialogs::Show 
FunctionEnd 

Function perform_mode 
    ${NSD_GetState} $hwndExecModeRadio $0 
    ${If} $0 = ${BST_CHECKED} 
     Call exec_mode 
    ${Else} 
     Call debug_mode 
    ${EndIF} 
FunctionEnd 

Function exec_mode 
    MessageBox mb_ok "exec_mode" 
FunctionEnd 

Function debug_mode 
    MessageBox mb_ok "debug_mode" 
FunctionEnd 
+0

雅它的工作。謝謝安德斯 – beginner

+0

如何在完成其工作後禁用此自定義按鈕? – beginner

+0

EnableWindow $ hwndExecModeRadio 0 – Anders