c - What is the difference between LVM_GETITEM and LVM_GETITEMTEXT? -
i want text of listview row (text of item , subitems), not sure if should use lvm_getitem
or lvm_getitemtext
.
what difference between these 2 messages, first retrieve entire information item or subitem while other retrieve text?
both lvm_getitem , lvm_getitemtext can used retrieve item's or subitem's text data. since retrieving item's text data common operation, lvm_getitemtext
message provided convenience implementation.
to illustrate difference, here 2 implementations using either message (error handling elided brevity):
std::wstring getlistviewitemtext( hwnd a_hwnd, int a_item, int a_subitem) { std::vector<wchar_t> buffer( 1024 ); lvitem lvi = { 0 }; lvi.mask = lvif_text; // required when using lvm_getitem lvi.psztext = buffer.data(); lvi.cchmaxtext = static_cast<int>( buffer.size() ); lvi.iitem = a_item; // required when using lvm_getitem lvi.isubitem = a_subitem; ::sendmessage( hwnd, lvm_getitem, 0, reinterpret_cast<lparam>( &lvi ) ); return std::wstring( lvi.psztext ); }
slightly shorter, using lvm_getitemtext
:
std::wstring getlistviewitemtext( hwnd a_hwnd, int a_item, int a_subitem) { std::vector<wchar_t> buffer( 1024 ); lvitem lvi = { 0 }; lvi.psztext = buffer.data(); lvi.cchmaxtext = static_cast<int>( buffer.size() ); lvi.isubitem = a_subitem; ::sendmessage( hwnd, lvm_getitemtext, a_item, reinterpret_cast<lparam>( &lvi ) ); return std::wstring( lvi.psztext ); }
Comments
Post a Comment