LB_SETITEMDATA 消息解释

最近用到ListBox的LB_SETITEMDATA消息, 还蛮有用的。

Sets a value associated with the specified item in a list box.

Parameters

wParam

Specifies the zero-based index of the item. If this value is -1, the lParam value applies to all items in the list box.

Windows 95/Windows 98/Windows Millennium Edition (Windows Me): The wParam parameter is limited to 16-bit values. This means list boxes cannot contain more than 32,767 items. Although the number of items is restricted, the total size in bytes of the items in a list box is limited only by available memory.

lParam

Specifies the value to be associated with the item.

Return Value

If an error occurs, the return value is LB_ERR.

Remarks

If the item is in an owner-drawn list box created without the LBS_HASSTRINGS style, this message replaces the value contained in the lParam parameter of the LB_ADDSTRING or LB_INSERTSTRING message that added the item to the list box.

这个函数给每个ListBox里的item一个绑定项(lParam),你只需要指定当前ListBox里的item的index就行。

注意lparam的解释:specifies the value to ba associated with the item. 就是说和相应的item绑定,而不是wParam里提到的index. 所以它可以安全地在LB_ADDSTRING和LB_INSERTSTRING里使用。也就是说当LB_ADDSTRING或LB_INSERTSTRING发生后,ListBox里的items次序发生改变,也不会影响每个item的绑定项。

这个消息在给listbox排序等操作时很有用哦。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值