ListView_Insertitem Help?

just write whatever you want

ListView_Insertitem Help?

Postby Armagedon » Tue May 27, 2008 2:56 pm

can you give me a example for insert item to Listview with ListView_InsertItem in delphi?
thanks :oops:
Armagedon
 
Posts: 14
Joined: Tue May 27, 2008 4:30 am

Code

Postby iconic » Mon Jun 09, 2008 12:24 am

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));


--Iconic
iconic
 
Posts: 833
Joined: Wed Jun 08, 2005 5:08 am


Return to fun talk

Who is online

Users browsing this forum: No registered users and 3 guests

cron