Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 21st September 2012, 09:44   #1
priyankaB
Junior Member
 
Join Date: Apr 2012
Posts: 7
NSD_CreateListBox - not able to get the selected item text

Hi there,

I am using "NSD_CreateListBox" to allow user to select a folder from the given list.
After the user selects an item, I need to fetch the text for that item, but my code fails to do so.

Also, i am using "custom page". Could anyone of you please help?
Here's the code snippet:-

code:

Function nsDialogsPage
nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateLabel} 20 20 100% 50 "Please select the folder to place the iptspy dll file"
${NSD_CreateListBox} 20 80 50% 100 ""
Pop $ListBox
${If} ${FileExists} "$INSTDIR\plugins\*.*"
${GetSize} "$INSTDIR\plugins" "/G=0" $0 $1 $2
StrCpy $searchdir1 "$INSTDIR\plugins"
FindFirst $0 $1 "$searchdir1\*.*"
${Do}
${If} $1 == "."
${OrIf} $1 == ".."
; do nothing
${ElseIf} ${FileExists} "$INSTDIR\plugins\$1\*.*"
${NSD_LB_AddString} $ListBox $1
${Else}
; message
${EndIf}
FindNext $0 $1
${LoopUntil} $1 == ""
FindClose $0
${Else}
; Message box
${EndIf}
nsDialogs::Show
FunctionEnd
Function nsDialogsPageLeave
; get the selected folder text
SendMessage $ListBox ${LB_GETCURSEL} 0 0 $0
${IF} $0 >= 0
;IntOp $1 $0 + 0;
SendMessage $ListBox ${LB_GETTEXT} $1 $0 $2
;System::Call "user32::SendMessage(i $ListBox,i ${LB_GETTEXT},i $1,t. $0)"
;System::Call user32::SendMessage(i$ListBox_left,i${LB_GETTEXT},i$0,t.r1)
MessageBox MB_OK "$2"
${ENDIF}
FunctionEnd



I am able to get the list populated, but not able to get the selected string/text.
priyankaB is offline   Reply With Quote
Old 21st September 2012, 09:56   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Just use ${NSD_GetText}.

Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 21st September 2012, 12:30   #3
priyankaB
Junior Member
 
Join Date: Apr 2012
Posts: 7
hi,

I placed below code in the customPage leave function:

${NSD_GetText} $ListBox $0
MessageBox MB_OK "$0"

I am sure it's done wrong way as it didn't worked...

Any suggestions?

thanks,
Priyanka
priyankaB is offline   Reply With Quote
Old 21st September 2012, 14:19   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,839
If you want to get the selection from a listbox, you should get the selection, not the text...

http://forums.winamp.com/showthread.php?threadid=276367
MSG is offline   Reply With Quote
Old 22nd September 2012, 04:25   #5
priyankaB
Junior Member
 
Join Date: Apr 2012
Posts: 7
I need to get the text of the selected item, since that will be the folder name into which the installer will place some DLLs.
priyankaB is offline   Reply With Quote
Old 22nd September 2012, 06:42   #6
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,839
The answer to that is already in the thread I linked.

http://forums.winamp.com/showthread....65#post2226265
MSG is offline   Reply With Quote
Old 22nd September 2012, 12:02   #7
priyankaB
Junior Member
 
Join Date: Apr 2012
Posts: 7
hey, I have already tried whats there in the link you shared, before raising the question on the forum. It didn't work for me.

I used :-
System::Call user32::SendMessage(i$MY_LIST_BOX,i${LB_GETTEXT},i$INDEX,t.$0)
But it throws warning "unknown variable/constant "INDEX""

Please ignore my inefficiency, I am new to NSIS scripting...
Please help!!..
priyankaB is offline   Reply With Quote
Old 22nd September 2012, 12:51   #8
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,839
...It's just an example, you cannot just simply copypaste it and expect it to work in your installer. Of course $INDEX is a variable containing the index of the item that you want to get the text/name of.
MSG is offline   Reply With Quote
Reply
Go Back   Winamp 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