can you give me a example for insert item to Listview with ListView_InsertItem in delphi?
thanks
ListView_Insertitem Help?
Code
Code: Select all
function InsertLvItem(const hLv: DWORD; lpText: PChar; dwIndex: DWORD): BOOL;
var
lvi: ^LV_ITEM;
const
dwSz = sizeof(lvi^);
begin
lvi := VirtualAlloc(nil, dwSz, MEM_COMMIT, PAGE_READWRITE);
lvi^.mask := LVIF_TEXT;
lvi^.pszText := lpText;
lvi^.iSubItem := 0;
lvi^.iItem := dwIndex;
result := ListView_InsertItem(hLv, lvi^) <> -1;
VirtualFree(lvi, 0, MEM_RELEASE);
end;
You can't insert subitems with the macro ListView_InsertItem but this works correctly for captions.
Example:
Code: Select all
if InsertLvItem(Lv.Handle, 'Item 1', 0) then
MessageBox(0, 'Item Inserted Successfully',
'Information', (MB_OK or MB_ICONINFORMATION or MB_TOPMOST or MB_SETFOREGROUND));