Hello,
I've created a dialog on which I have a listbox. To fill the listbox I use the following code:
This works just fine but when I want to retrieve the ItemData (not the visible text) I use the following code:
However, this does not work, all I get is a messagebox without any text.
Does anyone know how to solve this problem?
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?
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
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
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.
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.
Just wonder: shouldn't it be LB_GETCURSEL instead of LB_GETSEL?
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
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
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!
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!
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
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
Thanx Guy! :alright: