View Single Post
Old 4th August 2021, 12:35   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,449
Radio buttons sends BN_CLICKED when it gets focus, don't ask me why.

Quote:
...generation of BN_CLICKED messages when the button receives focus.
You can do
PHP Code:
!define /IfNDef BM_SETDONTCLICK 0xF8 Vista and later only?
SendMessage $hMyRadio ${BM_SETDONTCLICK1 0 
but when you use radio buttons, it is important to use groups and "check" one as the default. After that you don't care why you got notified:

PHP Code:
!include nsDialogs.nsh
Page Custom pre
Function pre
nsDialogs
::Create 1018
Pop 
$0
${NSD_CreateFirstRadioButton0 0 406"Configure $(^Name)"
Pop $1
${NSD_OnClick} $1 RadioChanged
${NSD_CreateAdditionalRadioButton0 12406"Just install now"
Pop $2
${NSD_OnClick} $2 RadioChanged
SendMessage 
$${BM_CLICK"" "" Set a default
nsDialogs::Show
FunctionEnd

Function RadioChanged
Pop 
$3
GetDlgItem 
$0 $hWndParent 1
${NSD_GetChecked} $$3
${If} $<> ${BST_UNCHECKED}
    ${
NSD_SetText} $"$(^NextBtn)"
${Else}
    ${
NSD_SetText} $"$(^InstallBtn)"
${EndIf}
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote