Archive: [nsDialogs] Multi-select Listbox?


[nsDialogs] Multi-select Listbox?
  Hi,

I thought it would be easy to create a multiple select listbox with nsDialogs, but obviously I was wrong. :rolleyes:

I have done the following:

${NSD_CreateListBox} 10u 70u 200u 35u $(LB_CleanUp) 

>Pop $ListBox_CleanUp
>${NSD_AddStyle} $ListBox_CleanUp ${LBS_MULTIPLESEL}
Adding the "LBS_MULTIPLESEL" should do the trick - but it did not.

After these lines I fill the listbox with several values - all works fine/ as expected.
But I can only choose one item at a time.

Is there anything wrong with the code?
Did I miss something?
Or what do I have to do to create a multiple select listbox with nsDialogs?

Thanks,

Gunther

Some styles you can't add after a control has been instantiated - LBS_MULTIPLESEL is one of them. You'll have to create the control manually from scratch.

Below is a code snippet to simply add a new ${NSD_Create* command, ${NSD_CreateListboxMultiselect}.

!define __NSD_ListBoxMultiselect_CLASS LISTBOX
!define __NSD_ListBoxMultiselect_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LBS_DISABLENOSCROLL}|${LBS_HASSTRINGS}|${LBS_NOINTEGRALHEIGHT}|${LBS_NOTIFY}|${LBS_MULTIPLESEL}
!define __NSD_ListBoxMultiselect_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
!insertmacro __NSD_DefineControl ListBoxMultiselect
>
I think the guys were still pondering options on how to make adding these types of styles -before- instantiating the control more flexible.

Originally posted by Animaether
Some styles you can't add after a control has been instantiated - LBS_MULTIPLESEL is one of them. You'll have to create the control manually from scratch.
Ahhh ..., that's the trap again ... :D, I see.

Then it is clear - thanks! :up:

Gunther

It's me again ... :p

Animaether's code works perfectly.
But now I have another problem ... :cry:

I gather some values and write them to a file before the page with the listbox is shown.
In the page's (show) function I check if the file exists and if so add each line from the file as an item to the listbox. And there is also one value deriving from a variable added to the listbox.

So far so good.
But on page leave (no matter if back or next) and first time returning to the page there is only the value coming from the variable!?
Leaving the page and returning again brings back all values!?

Any ideas?

Here is the code passage that reads the values from the file:


tmp

FileOpen $R0 $TEMPocpn_prev_installs
.tmp r
IfErrors done
${Do}
FileReadUTF16LE $R0 $0
${If} $0 == ""
Goto done
${Else}
FileReadUTF16LE $R0 $R1
SendMessage $ListBox_CleanUp${LB_ADDSTRING} 0 "STR:$R1"
${EndIf}
${Loop}
done:
FileClose $R0
>${EndIf}
What am I doing wrong this time ...? :o

Gunther

You probably want a ClearErrors at the top.

Edit: Also instead of Goto done and done: you can just use ${ExitDo} or ${Break}.

Stu


Stu,

Originally posted by Afrow UK
You probably want a ClearErrors at the top.
you are so right ...! :up:
I should remember to clear the error flag when using IfErrors ... :rolleyes:
Edit: Also instead of Goto done and done: you can just use ${ExitDo} or ${Break}.
Ah, OK - I see.

Thanks,

Gunther