Archive: NSD_CreateListBox - not able to get the selected item text


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:-


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.

Just use ${NSD_GetText}.

Stu


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


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


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.


The answer to that is already in the thread I linked.

http://forums.winamp.com/showthread....65#post2226265


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!!..


...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.