Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   Listbox Help (http://forums.winamp.com/showthread.php?t=209365)

PeterDev 2nd March 2005 20:57

Listbox Help
 
Hello,

How do I undate a ListBox dynamically ? I want to design a screen with the following fields:
- a directory selection field
- a listbox
- 5 button (add, remove, up, down, clear), where

Add adds an entry to the list (the value from the directory field). Remove removes the selected item from the list, Up/Down move the selected item up/down in the list, and clear clears the list.

Assistance is much appreciated.

Anders 2nd March 2005 21:42

-create a installoptions page with the needed controls
-add the notify flag to the buttons
-in the leave function for the page, change the contents of the listbox as needed using the system plugin

(InstallOptionsEx might support updating the items without using the system plugin)

Afrow UK 3rd March 2005 07:43

To add items to list box you can do the following:
code:

Var hwnd
!define LB_ADDSTRING 0x180
InstallOptions::initDialog /NOUNLOAD "ioFile.ini"
Pop $hwnd
GetDlgItem $R0 $hwnd 2002 # 2000 + Field # - 1
SendMessage $R0 ${LB_ADDSTRING} "STR:new item"
InstallOptions::display "ioFile.ini"



I might have the second InstallOptions function named wrongly... You'll have to check!

There are other ListBox messages which you'll have to search for either on Google, or MSDN.

-Stu

deguix 3rd March 2005 10:15

Quote:

(InstallOptionsEx might support updating the items without using the system plugin)
Not at this moment.

PeterDev 4th March 2005 01:36

Thanks for your help. Thanks for the link to the SendMessage function.

How do I get the selected item ... like so ?

GetDlgItem $R1 $hwnd 1204 # 1200 + Field # - 1
SendMessage $R1 ${LB_GETCURSEL} 0 0
Pop $R2

How do I selected an item ...

PeterDev 7th March 2005 19:50

If anyone has any ideas, please help ...

Thank you.

Afrow UK 7th March 2005 20:17

Use this to select a range of items:

!define LB_SELITEMRANGEEX 0x0183
SendMessage $R0 ${LB_SELITEMRANGEEX} ${From} ${To}

${From} is index to start from, and ${To} is where to stop.
First item would be index 0 (zero based).

Edit: And to un-select all the items again, use:
!define LB_SETSEL 0x0185
SendMessage $R0 ${LB_SETSEL} 0 -1

-Stu

PeterDev 7th March 2005 23:44

Thanks Stu,

One last question (I think) ...


I guess, to get the selected index, I need to define LB_GETSEL. What I am unsure about is hoe how to get the selected index, the value...

How do I get the value... I guess what I am unclear about is how to get a value from a function, either one that I have definedd or a pre-defined method, like SendMessage.

Thanks again.

Afrow UK 8th March 2005 07:40

The last paramatar for SendMessage can be the return value, and so:

SendMessage $R0 ${LB_GETSEL} 0 0 $R0
$R0 == current selected index

-Stu

PeterDev 8th March 2005 20:26

Thanks Stu, after posting that message, I tried it and it worked. I didn't get a chance to update ths thread.

I also tried the same approach for LB_GETTEXT (I think) to get the value, but I am getting -1. I wil read up.. but if you done this, I would appreciate if you could post the SendMessage call you used to get the selected value

Thanks a Lot !

Peter

Afrow UK 8th March 2005 21:18

If you want to get the current selected item in an InstallOptions ListBox, just use ReadINIStr, else this should work:

!define LB_GETSEL 0x0187
GetDlgItem $R1 $hwnd 1204 # 1200 + Field # - 1
SendMessage $R1 ${LB_GETSEL} 0 0 $R1

$R1 == selected index

-Stu

PeterDev 9th March 2005 00:18

Thanks for your help ! Much Appreciated !

Peter

PeterDev 9th March 2005 00:47

Actually Stu,

If you do not mind answering one more question...

The GETSEL does not see to work .. but the ReadINIStr does... so be it. What I want to do is read all its entries, then traverse them .. and write out each one in a file. I know how to write the file.. i need to do two thigs.

1) Read all the entries

State returns the selected value, ListItems .. no..
Text .. no..

2) Enumerate each "line"



Anyone .. ? thanks !!!

PeterDev 9th March 2005 00:52

I guess to get all, I can select them all (with SendMessage), and then get them using ReadINI... I will try it.. this is the first thought that came to mind.. and might be a weird way

Afrow UK 9th March 2005 09:57

I'm not sure if that will work. You're adding items with SendMessage but I don't know if the InstallOptions dll will write the added items back to the INI file afterwards...

There's probably a LB_GETRANGE message but I'll have to try it out when I get home (can't do anything here at college!)

-Stu

deguix 9th March 2005 11:33

Quote:

I'm not sure if that will work. You're adding items with SendMessage but I don't know if the InstallOptions dll will write the added items back to the INI file afterwards...
The items won't (to ListItems) but state items will.

PeterDev 9th March 2005 13:46

As Stu indicated, the ReadINIStr will read it from the current selected item. If I go next them back, the list is clear again.. need to write it to the ini or store it in a variable.

How do I write it to the ini ReadINIStr ?

Also, how to get all the values ? Whould writing to the ini, then reading ini (ReadStr), state give me the values.. I will try it..

Thanks

Afrow UK 9th March 2005 14:31

To write to the list, use WriteINIStr :)

You can read the list items and then loop through them using this function:
http://nsis.sourceforge.net/archive/...php?pageid=294

Do a loop like so:
code:

Loop:
Push "|" ;divider char
Push $R0 ;input string
Call SplitFirstStrPart
Pop $R1 ;1st part
Pop $R0 ;rest

# ... do stuff with $R1 here! ...

StrCmp $R0 "" 0 Loop ;loop if more list items



-Stu

tsuoying 24th March 2005 23:36

Hey guys, I'm doing something very similar and wanted to ask some specific questions. I'm using sendmessage to add items to a listbox. On "next", i need to get all the values in the listbox. As deguix said, the added items by sendmessage do not go into the ListItems, so how do I make it go in there, so then I can get it out, and also if I go to next page and then back, the list will still be there?

So, repeating PeterDev's question - how do I get all the values (on "Next")?, what're the specific sendmessage commands to do this? If I can do this, then I can use writeinistr to put it in the ListItems. Any help would be greatly appreciated!!

fluidz91 11th August 2006 10:58

Quote:

Originally posted by Afrow UK
To write to the list, use WriteINIStr :)

You can read the list items and then loop through them using this function:
http://nsis.sourceforge.net/archive/...php?pageid=294

Do a loop like so:
code:

Loop:
Push "|" ;divider char
Push $R0 ;input string
Call SplitFirstStrPart
Pop $R1 ;1st part
Pop $R0 ;rest

# ... do stuff with $R1 here! ...

StrCmp $R0 0 Loop ;loop if more list items



-Stu

Hi Afrow UK,

shouldn't it be :

StrCmp $R0 "" 0 Loop ;loop if more list items

instead of what you write :

StrCmp $R0 0 Loop ;loop if more list items

Moreover, i didn't understand how to get all the values from a listbox in installoptions so i can "push $R0" where $R0 is the input string of the listItems. Do i have to use GetDlgItem and SendMessage to do so ?

Afrow UK 11th August 2006 11:03

Yes it should be StrCmp $R0 "" 0 Loop.
Read from the State or ListItems flag with MUI_INSTALLOPTIONS_READ

-Stu

fluidz91 16th August 2006 15:11

Great Afrow UK, i didn't know ListItems Flag was readable.
It now works as expected.
Thx


All times are GMT. The time now is 05:11.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.