Archive: Disable Button


Disable Button
  Sorry not working

ReadRegDWORD$1 HKLM 'Software\Microsoft\NET Framework Setup\NDP\v2.00.50727' Install

!if !$1
Pop $R1
${NSD_CreateButton} 355 170u 7% 12u "Disable"
EnableWindow $R1 0
!EndIf
It does not work.

If Someone know please help me!

Thank alot.

you are mixing compile time and runtime, to use if's at runtime use the logic lib: ${If} $1 != 0 ...




ReadRegDWORD$0 HKLM 'Software\Microsoft\NET Framework Setup\NDP\v2.00.50727' Install
Pop $R0
${If} $1 != 0
${NSD_CreateButton} 355 170u 7% 12u "Disable"
EnableWindow $R1 0
${EndIf}
Thanks Anders can you example for see thanks.

didava,
You are reading the reg value into $0, but then comparing the value of $1. (huh?) And what's with the Pop $R1?

Unless there is something else you forgot to include, I'd say this is probably closer to what you meant:


!include logiclib.nsh
...

ReadRegDWORD $0 HKLM 'Software\Microsoft\.NET Framework Setup\NDP\v2.00.50727' Install
${If} $0 <> 0
${NSD_CreateButton} 355 170u 7% 12u "Disable"
EnableWindow $R1 0
${EndIf}

Thanks Comperio

I want to make a program in which we have one button. when we run the program, I want the button to be in a state in which: if the registry value was 'install', the button becomes active, and if it was 'noinstall', the button becomes inactive. and also please take a look at the above script and see what is its problem. thanks in advance.


ahh...
Try this:

!include logiclib.nsh
...
; create button first:
${NSD_CreateButton} 355 170u 7% 12u "Disable"
Pop $R1 ; R1 is the button handle at this point
; now, check registry and disable button if necessary:

ReadRegDWORD $0 HKLM 'Software\Microsoft\.NET Framework Setup\NDP\v2.00.50727' Install
ClearErrors
${Unless} $0 == "Install"
EnableWindow $R1 0
${EndUnless}
...
[continue your code here]
Remember that you have to show your page once you're done creating it (as outlined in the nsDialogs documentation). If you still have problems, then you may want to take some time to review the nsDialogs documentation and look at some of the examples included with NSIS itself.

edit: I changed the ${if} to an ${unless}

thank you so much Comperio .working :up: :)


hi dude! sorry to trouble you again and again. now I am confronted with a big problem. our variable has no more than 9. whereas for each button I use one variable. as a result, I was not able to create more than 10 buttons. I used Var, but it did not work. I have 30 buttons altogether, and I appreciate if you guide me.


$0-$9 and $R0-$R9 are built-in variables, but you can declare as many additional variables as you need.

Have a look a the examples of nsDialogs documentation that comes with NSIS. (It's installed with NSIS--look in the documentation folder.) You will find a very easy to follow tutorial on setting up a script using variables with nsDialogs.