Archive: Problem with WM_NEXTDLGCTL


Problem with WM_NEXTDLGCTL
I'm trying to create a page with 2 buttons. One of them it to replace the NEXT button. So I've used this line to make it default.

SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $BUTTON 1


The problem is when I click on the other button, instead of running the function click2, it runs the function click1. But on the second click it already goes to the function click2. More strange is, that if I do the first click in any place of the dialog, then when I click on the button2, it goes to the function click2.

Strange??

More strange. If I've just 1 page, everything works just fine.

Where goes a script so you can test it.

!include LogicLib.nsh
!include nsDialogs.nsh

Name "nsDialogs Timer Example"
OutFile "nsDialogs Timer Example.exe"
XPStyle on

Var DIALOG
Var BUTTON
Var BUTTON2

Page custom nsDialogsPage
Page directory

Function OnClick
MessageBox MB_OK "Click 1"
FunctionEnd

Function OnClick2
MessageBox MB_OK "Click 2"
FunctionEnd

Function nsDialogsPage

nsDialogs::Create 1018
Pop $DIALOG

; Create the buttons
${NSD_CreateButton} 15% 30% 70% 30% "Go"
Pop $BUTTON
${NSD_OnClick} $BUTTON onClick
; Set the Simple Button as the default button
SendMessage $BUTTON ${BM_SETSTATE} ${SW_SHOWDEFAULT} 1
SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $BUTTON 1 ; Problem is on this line


${NSD_CreateButton} 20% 65% 60% 20% "Advance"
Pop $BUTTON2
${NSD_OnClick} $BUTTON2 onClick2

nsDialogs::Show

FunctionEnd

Section
SectionEnd

It's actually the BM_SETSTATE line that does the trouble. You're specifying (with the wrong constant) that the button is pressed. When the user clicks on something else, it first "unclicks" the button and activates its OnClick function.


Thanks