简体   繁体   中英

NSIS message box custom buttons

I know this has been asked before and found several posts where they say no, but the most recent post I seen was from 2014, so I figure I would check to see if there is any new functionality I am missing.

Is there a way to change the message box buttons to custom text? So instead of YesNoCancel I can use UninstallReinstallCancel .

There are several message boxes I need to have this ability for.

If the option is write some custom plugin, could someone do this for me it would be over my head?

NSIS just uses the MessageBox Windows function and that does not allow you to set the button text.

The best option would be a custom plug-in but I doubt anyone is willing to write one for you just because you ask nicely. You could ask on the NSIS forum if anyone is willing to do it for a small fee perhaps.

As a workaround you can use the DlgHost plug-in on built-in pages to create a nested dialog with your own custom design:

!include nsDialogs.nsh
!include DlgHost.nsh

Page InstFiles

Function CloseDlgHostDialog
Pop $0
DlgHost::Close
FunctionEnd

Function DoSomethingElse
Pop $0
MessageBox mb_ok "Hello"
FunctionEnd

Function MyDlgBoxCallback
${Select} $0
${Case} ${DLGHOST_DLGBOXMSG_INITDLG}
    nsDialogs::Create 1018
    Pop $1
    DlgHost::SetClient $1

    ${NSD_CreateLabel} 25% 20% 45% 15u "Hello from nsDialogs..."
    Pop $1
    ${NSD_CreateButton} 10u 60% 50u 15u "&Close"
    Pop $1
    ${NSD_OnClick} $1 CloseDlgHostDialog

    ${NSD_CreateButton} 70u 60% 80u 15u "&Do something else"
    Pop $1
    ${NSD_OnClick} $1 DoSomethingElse

${Case} ${DLGHOST_DLGBOXMSG_SHOWDLG}
    nsDialogs::Show
${EndSelect}
FunctionEnd

Function ShowNSDChildDlg
GetFunctionAddress $0 MyDlgBoxCallback
DlgHost::DlgBox "* $0 p 200u 120u Test Dialog"
FunctionEnd

Section
Call ShowNSDChildDlg
SectionEnd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM