Hello,

I've created a dialog on which I have a listbox. To fill the listbox I use the following code:



invoke SendMessage, hListbox, LB_ADDSTRING, 0, addr TheDescription
invoke SendMessage, hListbox, LB_SETITEMDATA, eax, addr TheAction


This works just fine but when I want to retrieve the ItemData (not the visible text) I use the following code:



invoke SendMessage, [hListbox], LB_GETSEL,0,0
mov IndexItem, eax
INVOKE SendMessage, [hListbox], LB_GETITEMDATA, IndexItem, 0
mov Bufje, eax
INVOKE MessageBox, NULL, addr Bufje, addr szDisplayName, MB_OK+MB_ICONINFORMATION ;Show the retrieved ItemData


However, this does not work, all I get is a messagebox without any text.

Does anyone know how to solve this problem?
Posted on 2002-01-13 06:24:15 by pcdiks
Hi pcdiks

This is the bug:

INVOKE MessageBox, NULL, addr Bufje, addr szDisplayName, MB_OK+MB_ICONINFORMATION ;Show the retrieved ItemData

Should be:

INVOKE MessageBox, NULL, Bufje, addr szDisplayName, MB_OK+MB_ICONINFORMATION ;Show the retrieved ItemData

KetilO
Posted on 2002-01-13 08:41:50 by KetilO
I have tried that and it still gives me no result. Just an empty Messagebox...

Could it be that my input is not valid?
When I ask the value of TheAction with a messagebox right before the LB_SETITEMDATA it returns the correct data.
Posted on 2002-01-13 10:20:27 by pcdiks
Just wonder: shouldn't it be LB_GETCURSEL instead of LB_GETSEL?
Posted on 2002-01-13 11:23:28 by japheth
pcdiks you are requesting whether the item is selected or not using the LB_GETSEL message and you should be trying to get the index number of the selected item.

so instead of:

invoke SendMessage, , LB_GETSEL,0,0
mov IndexItem, eax


you will replace with:

invoke SendMessage, hListbox, LB_GETCURSEL,0,0
mov IndexItem, eax


this will get the selected items index number you will need when you send the message LB_GETITEMDATA
Posted on 2002-01-13 11:24:48 by smurf
And again, it does not work... :(

But thanx for the help! I think I'll just start over because now my program won't run on NT4 and W2K anymore, only XP... strange

Thanx!
Posted on 2002-01-14 04:15:09 by pcdiks
pcdiks,

You might want to try this example.
I'am not sure but I thing that LB_GETITEMDATA and LB_SETITEMDATA works with an ownerdraw listbox.

Anyway. just click on the items in the listbox and you'll see another text appear.

Guy
Posted on 2002-01-14 11:42:52 by Guy
Thanx Guy! :alright:
Posted on 2002-01-15 01:24:52 by pcdiks