自定义NSIS卸载程序确认页面

时间:2013-10-30 00:15:23

标签: nsis uninstaller mui nsdialogs

我在自定义NSIS卸载程序页面方面做了一些research,并在Welcome和Finish页面上取得了一些成功。

但是,我在使用“确认”页面的“欢迎”页面上使用相同的模板时遇到了问题。如果我add any control using nsDialogs的值为{0}非height,则“确认”页面上的所有现有控件(除标题和按钮外)都会消失。

这是我的代码(它成功更新了按钮名称,但将删除该页面上的所有其他控件)

!include MUI2.nsh

OutFile "CustomUninstaller.exe"
InstallDir "C:\Program Files (x86)\NSIS\Examples\CustomFinish"

!define APPNAME "Testing"
Name "${APPNAME}"

!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_WELCOME

!define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnConfirm ; My custom function for the Confirm page
!insertmacro MUI_UNPAGE_CONFIRM

!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

Function un.ModifyUnConfirm
    # Change "Uninstall" button to say "Continue" on uninstaller confirmation page
    GetDlgItem $0 $HWNDPARENT 1
    SendMessage $0 ${WM_SETTEXT} 0 "STR:Continue"

    # Add new label. If these three lines are commented out, I see the regular controls of this page show up.
    # The position, color and background of the label don't seem to matter
    ${NSD_CreateLabel} 50% 50% 100% 10u "Testing!!!"
    Pop $0
    SetCtlColors $0 "" ${MUI_BGCOLOR}
FunctionEnd

Section TestUninstaller
    WriteUninstaller "$INSTDIR\unCustomUninstaller.exe"
    ExecWait "$INSTDIR\unCustomUninstaller.exe"
Sectionend

问题:

  1. 有谁知道为什么控件会消失?
  2. 如何成功将控件添加到此页面,我需要做什么?

1 个答案:

答案 0 :(得分:2)

MUI_UNPAGE_CONFIRM不是nsDialogs页面!

要更改此对话框,您可以使用ChangeUI命令。 您还可以在运行时添加控件,但只能使用系统插件:

Function un.ModifyUnConfirm
    FindWindow $1 "#32770" "" $HWNDPARENT ; Find inner dialog
    System::Call 'USER32::CreateWindowEx(i${__NSD_Label_EXSTYLE},t"${__NSD_Label_CLASS}",t "Testing!!!",i${__NSD_Label_STYLE},i 50,i 100,i 400, i 25,i$1,i0,i0,i0)i.s'
    Pop $0
    SendMessage $HWNDPARENT ${WM_GETFONT} 0 0 $1
    SendMessage $0 ${WM_SETFONT} $1 1
    SetCtlColors $0 "" ${MUI_BGCOLOR} ; This is the wrong color to use...
FunctionEnd