0

我已经创建了带有两个单选按钮的自定义页面,用于修复和删除。如果用户选择修复按钮,它会带来修复乐趣。但再次来到修复和删除页面的旧页面。所以用户选择两个选项。我的要求是用户仅选择一个选项并仅执行相应的操作。无需提供同时选择两个按钮的选项。

     Function nsDialogpage
    nsDialogs::Create 1018
    Pop $Dialog
    ${If} $Dialog == error
       Abort
    ${EndIf}
    ${NSD_CreateRadioButton} 0 5u 100% 10u "Repair"
    Pop $Repair
    ${NSD_AddStyle} $Repair ${WS_GROUP}
    ${NSD_OnClick} $Repair Repair 
    ${NSD_CreateRadioButton} 0 25u 100% 56u "Remove"
    Pop $Remove
    ${NSD_OnClick} $Remove Remove
    nsDialogs::Show
FunctionEnd
Function Repair
-- Do repair function.
FunctionEnd
Function Remove
   ExecWait "$INSTDIR\uninstall.exe"
   Quit
FunctionEnd

如果删除乐趣也删除安装程序并退出安装。卸载程序已成功完成。但在该用户单击任何按钮后,安装程序再次进入主页,然后仅退出安装步骤。

1.用户选择任何一个选项并离开此修复和删除页面。

2.如果用户单击删除选项删除安装程序并立即退出该过程。

4

1 回答 1

0

Quit does not quit right away when used in a page action callback, it will quit when the page changes. Performing some action when a radio button is clicked is not normal Windows behavior (Try pressing TAB) so I added a normal example aswell.

!include nsDialogs.nsh
Page Custom RepairOrRemovePageInsane_Create
Page Custom RepairOrRemovePageNormal_Create RepairOrRemovePageNormal_Leave
Page InstFiles

Function Remove
ExecWait '"cmd" /C echo This is a dummy uninstall command...&pause' ; Call real uninstaller here
FunctionEnd

Function Repair
# Do repair....
FunctionEnd

Function RepairOrRemovePageInsane_Create
nsDialogs::Create 1018
Pop $0
${NSD_CreateRadioButton} 0 5u 100% 10u "Repair"
Pop $0
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $0 1
${NSD_OnClick} $0 RepairInsane
${NSD_CreateRadioButton} 0 25u 100% 56u "Remove"
Pop $0
${NSD_OnClick} $0 RemoveInsane
GetDlgItem $0 $hwndparent 1 ; Get Next button handle and
EnableWindow $0 0 ; ...disable it because it does not make sense with this insane radio button handling
nsDialogs::Show
FunctionEnd

Function RemoveInsane
Call Remove
SendMessage $HWNDPARENT ${WM_CLOSE} 0 0 
FunctionEnd

Function RepairInsane
Call Repair
SendMessage $HWNDPARENT 0x408 1 0 ; Go to next page
FunctionEnd

Function RepairOrRemovePageNormal_Create
nsDialogs::Create 1018
Pop $1
${NSD_CreateRadioButton} 0 5u 100% 10u "Repair"
Pop $1
${NSD_CreateRadioButton} 0 25u 100% 56u "Remove"
Pop $2
SendMessage $1 ${BM_CLICK} 0 0 ; Select one of them by default
nsDialogs::Show
FunctionEnd

Function RepairOrRemovePageNormal_Leave
${NSD_GetState} $1 $0
${If} $0 <> 0
    Call Repair
${Else}
    Call Remove
    Quit
${EndIf}
FunctionEnd
于 2012-11-21T04:10:18.093 回答