WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > nsDialogs - using ${NSD_CreateListBox}
  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
johnbm
Junior Member

Registered: Aug 2007
From:

nsDialogs - using ${NSD_CreateListBox}

I'm interested in using a listbox in nsDialogs. It's unclear to me from the documentation I have seen though how one can populate the listbox and once this is done how one captures the selection made in the listbox.

If I use the code:

${NSD_CreateListBox} 100 40 20% 12u "sample entry"

it will create a blank listbox.

Would anyone be able to clarify this for me?

Thanks, John

Quick Link | Report this post to a moderator | IP: Logged

johnbm is offline Old Post 08-23-2007 08:23 PM
Click Here to See the Profile for johnbm Find more posts by johnbm Add johnbm to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

You can add items with LB_ADDSTRING.

code:
${NSD_CreateListBox} 100 40 20% 12u "" Pop $ListBox SendMessage $ListBox ${LB_ADDSTRING} 0 "STR:Simple entry" SendMessage $ListBox ${LB_ADDSTRING} 0 "STR:Another entry" SendMessage $ListBox ${LB_ADDSTRING} 0 "STR:Blah"

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 08-24-2007 07:36 AM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
jeffadams78
Junior Member

Registered: Aug 2007
From:

How do you get the selection from the list box? And can you have a change function?

GetFunctionAddress $0 OnMyListBoxChange
nsDialogs::OnChange /NOUNLOAD $MY_LIST_BOX $0

Doesn't seem to work...

Quick Link | Report this post to a moderator | IP: Logged

jeffadams78 is offline Old Post 08-24-2007 03:51 PM
Click Here to See the Profile for jeffadams78 Click here to Send jeffadams78 a Private Message Find more posts by jeffadams78 Add jeffadams78 to your buddy list Edit/Delete Message Reply w/Quote
Afrow UK
Moderator

Registered: Nov 2002
From: Shropshire, England

Look up MSDN for LB_ADDSTRING and you will see all the other list box messages available.

Stu

__________________
afrowuk.co.uk

Quick Link | Report this post to a moderator | IP: Logged

Afrow UK is offline Old Post 08-24-2007 04:26 PM
Click Here to See the Profile for Afrow UK Click here to Send Afrow UK a Private Message Click Here to Email Afrow UK Visit Afrow UK's homepage! Find more posts by Afrow UK Add Afrow UK to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

Send LB_GETCURSEL to get the selected state of an item.

code:
SendMessage $MY_LIST_BOX ${LB_GETCURSEL} 0 0 $0 # $0 will not be zero if the item is selected
List box notification is only sent when the LBS_NOTIFY style is used. I have added it to the next version of nsDialogs.nsh. For the current version, you can manually create the list box when the desired flags or add |${LBS_NOTIFY} to the definition of __NSD_ListBox_STYLE in nsDialogs.nsh.

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 08-24-2007 04:33 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
jeffadams78
Junior Member

Registered: Aug 2007
From:

LB_GETCURSEL returns the index or "LB_ERR" if no line is selected. Any idea what LB_ERR is? -1? You don't appear to have it defined in nsDialogs.nsh. The index is supposedly 0-based, so 0 is valid (first line).

Quick Link | Report this post to a moderator | IP: Logged

jeffadams78 is offline Old Post 08-24-2007 05:39 PM
Click Here to See the Profile for jeffadams78 Click here to Send jeffadams78 a Private Message Find more posts by jeffadams78 Add jeffadams78 to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

It's -1.

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 08-24-2007 05:47 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
jeffadams78
Junior Member

Registered: Aug 2007
From:

You beat me to the post . LB_ERR = -1... because that's what I get back every time I send the LB_GETCURSEL message. Any idea why that would be?------

Nevermind, it was a bug in my code, I get the correct value from the message I wasn't copying it into the right variable.

Manually creating the list box with LBS_NOTIFY worked great though as far as getting OnChange notifications.

Thanks!

Quick Link | Report this post to a moderator | IP: Logged

jeffadams78 is offline Old Post 08-24-2007 05:48 PM
Click Here to See the Profile for jeffadams78 Click here to Send jeffadams78 a Private Message Find more posts by jeffadams78 Add jeffadams78 to your buddy list Edit/Delete Message Reply w/Quote
jeffadams78
Junior Member

Registered: Aug 2007
From:

Any reason why LB_GETTEXT wouldn't work? I'm trying to get the text that the user selected, and I think this should work:

SendMessage $MY_LIST_BOX ${LB_GETCURSEL} 0 0 $0
${IF} $0 >= 0
IntOp $1 $0 + 0;
SendMessage $MY_LIST_BOX ${LB_GETTEXT} $1 $0 $2
MessageBox MB_OK '0: $0, 1: $1, 2: $2'
${ENDIF}

I always get back: $0 is the correct index (from the first SendMessage, the second one fails and doesn't write to it), $1 is the same (since I copied $0 into it), and $2 is LB_ERR, which according to the MSDN means that I passed an invalid index... but it is valid.

Quick Link | Report this post to a moderator | IP: Logged

jeffadams78 is offline Old Post 08-24-2007 06:08 PM
Click Here to See the Profile for jeffadams78 Click here to Send jeffadams78 a Private Message Find more posts by jeffadams78 Add jeffadams78 to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

Yes, you need System::Call for that. SendMessage alone can't handle strings returning from the message.

code:
System::Call user32::SendMessage(i$MY_LIST_BOX,i${LB_GETTEXT},i$INDEX,t.$0)

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 08-24-2007 06:10 PM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
jeffadams78
Junior Member

Registered: Aug 2007
From:

Hmm, that still didn't work. I've actually changed my mind and decided that the index is fine for my purposes, but thanks for your help.

Quick Link | Report this post to a moderator | IP: Logged

jeffadams78 is offline Old Post 08-24-2007 06:21 PM
Click Here to See the Profile for jeffadams78 Click here to Send jeffadams78 a Private Message Find more posts by jeffadams78 Add jeffadams78 to your buddy list Edit/Delete Message Reply w/Quote
johnbm
Junior Member

Registered: Aug 2007
From:

kichik thanks for your help, that worked well and it's pointed me in the right direction on a number of things. I'm now trying to create a combobox with a dropdown style.

${NSD_CreateComboBox} 200 20 20% 59u ""
Pop $ComboBox
SendMessage $ComboBox ${CB_ADDSTRING} 0 "STR:First Entry"
SendMessage $ComboBox ${CB_ADDSTRING} 0 "STR:Second Entry"
SendMessage $ComboBox ${CB_ADDSTRING} 0 "STR:Third Entry"

I know that I need to use CBS_DROPDOWN to set the style and I expect that I add this as an extra parameter to

${NSD_CreateComboBox} 200 20 20% 59u ""

but I'm not sure of the syntax.

I believe one may also be able to do this by using CreateWindow. Does anyone know how this is done?

Quick Link | Report this post to a moderator | IP: Logged

johnbm is offline Old Post 08-24-2007 07:22 PM
Click Here to See the Profile for johnbm Find more posts by johnbm Add johnbm to your buddy list Edit/Delete Message Reply w/Quote
klopfdreh
Junior Member

Registered: Feb 2008
From:

Hello,

I saw that thread about ListBox and I tried it by myself, but this codesnippet below doesn't work for me:

PHP:

${NSD_CreateListBox} 0 60 100% 100% ""
Pop $ListBox
SendMessage $ListBox
${LB_ADDSTRING} 0 "HELLOOO"



I defined a Var ListBox and the Compiler compiled it without any errors.

Thanks so far!

Quick Link | Report this post to a moderator | IP: Logged

klopfdreh is offline Old Post 02-13-2008 10:10 AM
Click Here to See the Profile for klopfdreh Click here to Send klopfdreh a Private Message Click Here to Email klopfdreh Find more posts by klopfdreh Add klopfdreh to your buddy list Edit/Delete Message Reply w/Quote
kichik
M.I.A.
[NSIS Dev, Mod]

Registered: Oct 2001
From: Jerusalem, Israel

Use "STR:HELLOOO" instead of just "HELLOOO".

__________________
NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius

Quick Link | Report this post to a moderator | IP: Logged

kichik is offline Old Post 02-13-2008 10:14 AM
Click Here to See the Profile for kichik Click here to Send kichik a Private Message Visit kichik's homepage! Find more posts by kichik Add kichik to your buddy list Edit/Delete Message Reply w/Quote
klopfdreh
Junior Member

Registered: Feb 2008
From:

Thanks kichik - thats right!

And how can I clear the list?

Edit: Saw it in some CPP Code

PHP:

SendMessage $ListBox
${LB_RESETCONTENT} 0 0



Thanks a lot!

P.S.:

May you are able to help me with DialogsEx? I have another post here with a problem which hasn't been solved yet:

Topic:
Custom Page with FileSelect-Button

URL:
URL submitted by user.

Last edited by klopfdreh on 02-13-2008 at 10:44 AM

Quick Link | Report this post to a moderator | IP: Logged

klopfdreh is offline Old Post 02-13-2008 10:20 AM
Click Here to See the Profile for klopfdreh Click here to Send klopfdreh a Private Message Click Here to Email klopfdreh Find more posts by klopfdreh Add klopfdreh to your buddy list Edit/Delete Message Reply w/Quote
Ivan Andreevich
Junior Member

Registered: Nov 2003
From: Vancouver, BC

Ah, this was something I was looking for.

I am using an nsDialogs DropList, so my code is slightly different. Here it is for reference. It's combo box commands.

Clear droplist:
SendMessage $DropList ${CB_RESETCONTENT} 0 0

Add entry ($1) to droplist:
SendMessage $DropList ${CB_ADDSTRING} 0 "STR:$1"

Select entry ($1) in the droplist:
SendMessage $DropList ${CB_SELECTSTRING} 0 "STR:$1"

Ivan

Quick Link | Report this post to a moderator | IP: Logged

Ivan Andreevich is offline Old Post 12-16-2008 07:23 PM
Click Here to See the Profile for Ivan Andreevich Click here to Send Ivan Andreevich a Private Message Click Here to Email Ivan Andreevich Find more posts by Ivan Andreevich Add Ivan Andreevich to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 09:33 AM. Post New Thread    Post A Reply
  Last Thread   Next Thread
WINAMP.COM | Forums : Powered by vBulletin version 2.3.9 WINAMP.COM | Forums > Developer Center > NSIS Discussion > nsDialogs - using ${NSD_CreateListBox}
Show Printable Version
 | 
Email this Page
 | 
Subscribe to this Thread

Forum Jump:
 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is off
vB code is ON
Smilies are ON
[IMG] code is ON