Adding a checkbox to the NSIS Uninstaller Welcome Page

前端 未结 1 732
别跟我提以往
别跟我提以往 2021-01-15 03:41

I\'m trying to add a checkbox to the welcome screen of my NSIS uninstaller, but I\'m having trouble finding an example. From the documentation for MUI2 I can\'t find any cus

相关标签:
1条回答
  • 2021-01-15 04:06

    The MUI(1) documentation you linked to has a note about how you can customize the welcome page in the pre/show callbacks. With MUI2 you can add controls in the show callback. See the nsDialogs documentation for more information about these custom controls...

    !include MUI2.nsh
    !insertmacro MUI_PAGE_INSTFILES
    !define MUI_PAGE_CUSTOMFUNCTION_SHOW un.ModifyUnWelcome
    !define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.LeaveUnWelcome
    !insertmacro MUI_UNPAGE_WELCOME
    !insertmacro MUI_UNPAGE_INSTFILES
    !insertmacro MUI_LANGUAGE English
    
    Var mycheckbox ; You could just store the HWND in $1 etc if you don't want this extra variable
    
    Function un.ModifyUnWelcome
    ${NSD_CreateCheckbox} 120u -18u 50% 12u "Do something special"
    Pop $mycheckbox
    SetCtlColors $mycheckbox "" ${MUI_BGCOLOR}
    ${NSD_Check} $mycheckbox ; Check it by default
    FunctionEnd
    
    Function un.LeaveUnWelcome
    ${NSD_GetState} $mycheckbox $0
    ${If} $0 <> 0
        MessageBox mb_ok "I'm special"
    ${EndIf}
    FunctionEnd
    
    Section testuninstaller
    Initpluginsdir
    WriteUninstaller "$pluginsdir\u.exe"
    ExecWait '"$pluginsdir\u.exe" _?=$pluginsdir'
    Sectionend
    
    0 讨论(0)
提交回复
热议问题