LB_SETITEMDATA 訊息解釋

來源:互聯網
上載者:User

最近用到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排序等操作時很有用哦。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.