ListView_Insertitem Help?
Posted: Tue May 27, 2008 2:56 pm
can you give me a example for insert item to Listview with ListView_InsertItem in delphi?
thanks
thanks
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;
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));