!include nsDialogs.nsh Name "nsDialogs Example" OutFile "nsDialogs Example.exe" ; Well use these global variables for the control handles. ; This way we don't need to worry about the registers and ; avoid the push and pop hell. ;) Var CONTROL1 Var CONTROL2 Var CONTROL3 Var CONTROL4 Page custom nsDialogsPage Function nsDialogsPage nsDialogs::Create /NOUNLOAD 1018 Pop $0 ${NSD_CreateText} 10u 16u -20u 13u $CONTROL1 Pop $CONTROL1 ; Always remember! Even if you don't use the notification ; callback functions, the HWND is still pushed in the stack ; and it should be popped to prevent stack corruption. GetFunctionAddress $0 OnStackSpam nsDialogs::OnChange /NOUNLOAD $CONTROL1 $0 ${NSD_CreateText} 10u 38u -20u 13u $CONTROL2 Pop $CONTROL2 GetFunctionAddress $0 OnStackSpam nsDialogs::OnChange /NOUNLOAD $CONTROL2 $0 ${NSD_CreateText} 10u 60u -20u 13u $CONTROL3 Pop $CONTROL3 GetFunctionAddress $0 OnStackSpam nsDialogs::OnChange /NOUNLOAD $CONTROL3 $0 ${NSD_CreateLabel} 10u 78u -20u 9u "Select one..." Pop $R0 ${NSD_CreateListBox} 10u 90u -20u 28u $R4 Pop $CONTROL4 ; This time we have some use for the OnChange callback function ; so we use the a function that actually does something. GetFunctionAddress $0 OnLBChange nsDialogs::OnChange /NOUNLOAD $CONTROL4 $0 SendMessage $CONTROL4 ${LB_ADDSTRING} 0 "STR:val1" SendMessage $CONTROL4 ${LB_ADDSTRING} 0 "STR:val2" SendMessage $CONTROL4 ${LB_ADDSTRING} 0 "STR:val3" ; Let's disable the three edit controls we created. EnableWindow $CONTROL1 0 EnableWindow $CONTROL2 0 EnableWindow $CONTROL3 0 nsDialogs::Show FunctionEnd Function OnStackSpam ; Just to keep the stack clean Pop $0 # HWND FunctionEnd Function OnLBChange Pop $0 # HWND ; $0 == $CONTROL4 ; This message gets index of the currently selected item ; from the ListBox control. SendMessage $0 ${LB_GETCURSEL} 0 0 $R0 ; if first item is selected. StrCmp $R0 "0" 0 +4 EnableWindow $CONTROL1 1 EnableWindow $CONTROL2 0 EnableWindow $CONTROL3 0 ; if second item is selected. StrCmp $R0 "1" 0 +4 EnableWindow $CONTROL1 0 EnableWindow $CONTROL2 1 EnableWindow $CONTROL3 0 ; if third item is selected. StrCmp $R0 "2" 0 +4 EnableWindow $CONTROL1 0 EnableWindow $CONTROL2 0 EnableWindow $CONTROL3 1 FunctionEnd Section SectionEnd