Old 19th January 2016, 18:59   #1
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Change textbox text at runtime

Hi All,

I have a custom dialog I created using NSD from the Coolsoft NSIS designer.
I have a check box on the Dialog with some standard string say "Check this".
I am trying to change the Value of this during runtime. The code from the dialog designer is below:

; === CheckBox1 (type: Checkbox) ===
${NSD_CreateCheckbox} 50.03u 73.23u 110.58u 14.77u "Check This"
Pop $hCtl_ExistingHub_CheckBox1

If I do this in my installer, it doesnt change the text:

${NSD_SetText} $hCtl_ExistingHub_CheckBox1 "Check that"
I tried putting this line before calling the function that shows the page.

Any inputs?
pkonduru is offline   Reply With Quote
Old 20th January 2016, 08:21   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 916
If you want to change the text before showing the page, just change the text in the first line (the one that creates the checkbox). If you want to change the text when it's clicked, you have to use a function callback and use ${NSD_SetText} in that.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 20th January 2016, 21:03   #3
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Hi Jason,

Thank you for the reply. The problem with the Coolsoft NSIS designer is one cannot edit the code that it generates, within the .nsdinc file. So,I was thinking if there is anyway say I make a list box/ checkbox and generate the list items or checkbox items from my .nsi file.
pkonduru is offline   Reply With Quote
Old 21st January 2016, 08:14   #4
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 916
Does it set the read-only flag on the .nsdinc file? (right click -> Properties -> Attributes:).

Unfortunately it becomes very difficult to manage both user code and wizard generated code. NSIS is a scripting language, eventually you will learn how to code installers from scratch if you use it often enough.

I would say do as much as you can in the wizard, then manually add the extra bits you need. I would say if you use the wizard again after this, it would probably overwrite all the extra code you put in, wasting more time.

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 21st January 2016, 19:42   #5
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
It works just fine, you must be doing something wrong:

PHP Code:
Var MyCheckbox
Page Custom MyPage
Page InstFiles
!include nsDialogs.nsh
Function MyPage
nsDialogs
::Create 1018
Pop 
$0
${NSD_CreateCheckbox50.03u 73.23u 110.58u 14.77u "Check This"
Pop $MyCheckbox
${NSD_SetText$MyCheckbox "Check that"
nsDialogs::Show
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 27th January 2016, 23:11   #6
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Thanks Jason, thats what am doing these days. Just generating the UI code using the designer and using that in my installer.
Like you mentioned editing the file and re-opening again in wizard overwrites all my changes.
pkonduru is offline   Reply With Quote
Old 27th January 2016, 23:12   #7
pkonduru
Member
 
Join Date: Jul 2015
Posts: 62
Hi Anders,

Thank you for your repky.
Yes, the piece of code you provided works fine but the Createcheckbox is in the designer code and the settext is in my nsi which doesnt seem to work.
pkonduru is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump