Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 2nd March 2005, 20:57   #1
PeterDev
Guest
 
Posts: n/a
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.
  Reply With Quote
Old 2nd March 2005, 21:42   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 2,775
-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)

IntOp $PostCount $PostCount + 1
Anders is online now   Reply With Quote
Old 3rd March 2005, 07:43   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 3rd March 2005, 10:15   #4
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,351
Send a message via ICQ to deguix
Quote:
(InstallOptionsEx might support updating the items without using the system plugin)
Not at this moment.

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 4th March 2005, 01:36   #5
PeterDev
Guest
 
Posts: n/a
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 ...
  Reply With Quote
Old 7th March 2005, 19:50   #6
PeterDev
Guest
 
Posts: n/a
Question

If anyone has any ideas, please help ...

Thank you.
  Reply With Quote
Old 7th March 2005, 20:17   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 7th March 2005, 23:44   #8
PeterDev
Guest
 
Posts: n/a
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.
  Reply With Quote
Old 8th March 2005, 07:40   #9
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
The last paramatar for SendMessage can be the return value, and so:

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

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 8th March 2005, 20:26   #10
PeterDev
Guest
 
Posts: n/a
Question

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
  Reply With Quote
Old 8th March 2005, 21:18   #11
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 9th March 2005, 00:18   #12
PeterDev
Guest
 
Posts: n/a
Thanks for your help ! Much Appreciated !

Peter
  Reply With Quote
Old 9th March 2005, 00:47   #13
PeterDev
Guest
 
Posts: n/a
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 !!!
  Reply With Quote
Old 9th March 2005, 00:52   #14
PeterDev
Guest
 
Posts: n/a
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
  Reply With Quote
Old 9th March 2005, 09:57   #15
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 9th March 2005, 11:33   #16
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,351
Send a message via ICQ to deguix
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.

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 9th March 2005, 13:46   #17
PeterDev
Guest
 
Posts: n/a
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
  Reply With Quote
Old 9th March 2005, 14:31   #18
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
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

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 24th March 2005, 23:36   #19
tsuoying
Junior Member
 
Join Date: Mar 2005
Location: SF
Posts: 9
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!!
tsuoying is offline   Reply With Quote
Old 11th August 2006, 10:58   #20
fluidz91
Member
 
Join Date: Jun 2006
Location: Paris - FR
Posts: 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 ?
fluidz91 is offline   Reply With Quote
Old 11th August 2006, 11:03   #21
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Birmingham, England
Posts: 8,202
Yes it should be StrCmp $R0 "" 0 Loop.
Read from the State or ListItems flag with MUI_INSTALLOPTIONS_READ

-Stu

Need an installer? http://www.afrowsoft.co.uk
Afrow UK is offline   Reply With Quote
Old 16th August 2006, 15:11   #22
fluidz91
Member
 
Join Date: Jun 2006
Location: Paris - FR
Posts: 58
Great Afrow UK, i didn't know ListItems Flag was readable.
It now works as expected.
Thx
fluidz91 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