congahonga
28th January 2009 13:28 UTC
Variables from nsDialog in Section
Hi there,
I am going like this:
Function nsDialogsABRServerPage
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 160 20 "Server Einstellungen"
${NSD_CreateLabel} 0 15 160 20 "================"
${NSD_CreateLabel} 0 50 160 20 "Server Name"
${NSD_CreateText} 180 50 200 20 ""
Pop $DB_SERVER
${NSD_CreateLabel} 0 75 160 20 "1.IP-Adresse Server:"
${NSD_CreateText} 180 75 200 20 "12.169.125.173"
Pop $SERVER_IP1
${NSD_CreateLabel} 0 100 160 20 "2.IP-Adresse Server:"
${NSD_CreateText} 180 100 200 20 ""
Pop $SERVER_IP2
nsDialogs::Show
FunctionEnd
Function nsDialogsABRServerPageLeave
${NSD_GetText} $DB_SERVER $0
MessageBox MB_OK "You typed:$\n$\n$0"
FunctionEnd
This function I use with the plugin "nsDialog".
My Question:
How can I get access from the Section to the variable
$DB_SERVER in the function !
This doesn't work ! Why ?
Section ""
DetailPrint $DB_SERVER
DetailPrint $SERVER_IP1
SectionEnd
(I use "Var " to declare all variables ! No Errors in NSIS Code)
Please help me !!!
Thank you
Jochen Graulberger from BLACK-FORREST !
kichik
28th January 2009 23:28 UTC
Why would you want to print out the HWND of the text control? Are you trying to print its value? If so, it's in $0 according to your code.
congahonga
29th January 2009 08:58 UTC
Variables from nsDialog in Section
No, i want to keep the results in $DB_SERVER and $SERVER_IP because I need them in some other places.
There are more custom pages, I need for every custom page a
...leave function to proove if values are correct syntax.
Now its only blablaba for first test reasons.
But I need the results in $DB_SERVER....usw.
Function nsDialogsABRServerPageLeave
${NSD_GetText} $DB_SERVER $0
MessageBox MB_OK "You typed:$\n$\n$0"
FunctionEnd
Does this really DELETE the value in $DB_SERVER ?
How could I preserve this variable for global use
Greetings
Jochen Graulberger
Animaether
29th January 2009 12:00 UTC
Jochen,
What kichik means is that $DB_SERVER doesn't contain the text that the user entered, but rather contains a pointer to the text element (which contains the graphics and code behind it) in the user interface itself.
When you use "${NSD_GetText} $DB_SERVER $0", that's when nsDialogs takes the text -from- that element and puts it in $0 .
So if the user entered "Hello World", then $0 is what would contain "Hello World".
$0 is one of NSIS's internal variables, and chances are that you may overwrite them later on. So what you'll want to do is add a new variable, for example:
Var DB_SERVER_VALUE
Then let nsDialogs take the text from $DB_SERVER and put it in $DB_SERVER_VALUE instead:
${NSD_GetText} $DB_SERVER $DB_SERVER_VALUE
After that command, you can then use $DB_SERVER_VALUE anywhere else - in Functions, Sections, callbacks, etc.
So in your example case...
Section ""
DetailPrint $DB_SERVER_VALUE
DetailPrint $SERVER_IP1_VALUE
SectionEnd
I hope that makes it a bit more clear for you :)
tlcooley
13th May 2009 19:53 UTC
This makes perfect sense, but for some reason is not working for me. Here is my code:
Function StoreInformation
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateText} 60u 20u 25% 10u ""
Pop $TextTID
${NSD_CreateLabel} 42u 20u 30% 10u "TID:"
Pop $LabelTID
Function nsDialogsPageLeave1
${NSD_GetText} $TextTID $TID
MessageBox MB_OK "You typed:$\n$\n$TID"
The Message box is displaying a blank response. It just shows up as "You typed: "
Animaether
13th May 2009 20:18 UTC
Your example is incomplete, so I can't tell where the error would be. Here's a complete example that works:
!addplugindir "."
!addincludedir "."
!include "nsDialogs.nsh"
!include "winmessages.nsh"
!include "logiclib.nsh"
!include "MUI2.nsh"
OutFile "test.exe"
var dialog
var hwnd
var null
var TextTID
var LabelTID
var TID
Page custom StoreInformation nsDialogsPageLeave1
Page instfiles
Function StoreInformation
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateText} 60u 20u 25% 10u ""
Pop $TextTID
${NSD_CreateLabel} 42u 20u 30% 10u "TID:"
Pop $LabelTID
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave1
${NSD_GetText} $TextTID $TID
MessageBox MB_OK "[nsDialogsPageLeave1] You typed:$\n$\n$TID"
FunctionEnd
Section
MessageBox MB_OK "[SECTION] You typed:$\n$\n$TID"
SectionEnd
!insertmacro MUI_LANGUAGE "English"