473,325 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

SetOverlayImage in windows forms ListView

How do I set overlay images for ListViewItems in a Windows Forms
ListView? I want to overlay an additional Icon on top of the
ListViewItem's icon. Since I can do this in MFC/Win32 I suppose this
API is somehow exposed in WindowsForms too ? Or do I have to use P/
Invoke myself? If so, is there an (c#, VB.NET) example around
somewhere that shows me how to do it ?

Feb 19 '07 #1
1 6436
On 19 Feb., 16:48, "Robert Ludig" <schwertfischtromb...@gmx.dewrote:
How do I set overlay images for ListViewItems in a Windows Forms
ListView? I want to overlay an additional Icon on top of the
ListViewItem's icon. Since I can do this in MFC/Win32 I suppose this
API is somehow exposed in WindowsForms too ? Or do I have to use P/
Invoke myself? If so, is there an (c#, VB.NET) example around
somewhere that shows me how to do it ?
I tried the followinng simple code. Do you see any mistakes (because
sendmessage returns 1, but nothing happens - no overlay image is
set) ?:

[StructLayout(LayoutKind.Sequential)]
struct LVITEM
{
public uint mask;
public int iItem;
public int iSubItem;
public uint state;
public uint stateMask;
public string pszText;
public int cchTextMax;
public int iImage;
public int lParam;
public int iIndent;
public int iGroupId;
public uint cColumns;
public uint puColumns;
}
public partial class Form1 : Form
{
[DllImport("comctl32.dll")]
public extern static bool ImageList_SetOverlayImage(int himl,
int iImage, int iOverlay);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int
wParam, int lParam);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
listView1.Items.Add("aa", 0);
}
private void button1_Click(object sender, EventArgs e)
{
LVITEM item = new LVITEM();
item.stateMask = 0x0F00; /*LVIS_OVERLAYMASK*/
item.state = 1 << 8 /*INDEXTOOVERLAYMASK(1)*/;
ImageList_SetOverlayImage(imageList1.Handle.ToInt3 2(), 1,
1);
int x = SendMessage(this.listView1.Handle.ToInt32(),
0x1000 + 43/*LVM_SETITEMSTATE*/, -1/*all items*/,
((IntPtr)GCHandle.Alloc(item)).ToInt32());
}
......
Feb 20 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Wiktor Zychla | last post by:
today we've found a critical issue regarding the ListView from Windows.Forms. it was confirmed on several machines with Win2K and XP. here's the problem: create a ListView with about 50000 rows....
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
2
by: Ryan Liu | last post by:
Hi, Can someone give me a hlep on inherited user control? I try to inherite windows forms user control, like ListView. From Visual studio 2003, I right click a folder and selct "Add...
0
by: Robert Ludig | last post by:
How do I set overlay images for ListViewItems in a Windows Forms ListView? I want to overlay an additional Icon on top of the ListViewItem's icon. Since I can do this in MFC/Win32 I suppose this...
2
by: jmDesktop | last post by:
I have two listview controls. I have three items of text. I can drag and drop the listview items between each other, back and forth. But the images from the imagelist do not copy over from...
0
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
2
by: Peter | last post by:
Hi, I have a problem with Listview using checkboxes. If i check items by code BEFORE the form is shown the Listview.Items are confused during the ItemChecked Event !!! After showing the...
2
by: win | last post by:
The SortKey of VB6 is not in .Net. Can I still do sorting using a listview? Thanks
1
by: =?Utf-8?B?QW5kcmV3?= | last post by:
I am trying to adapt some code that I have where I drag and drop from two treeview controls. Now I want to drag and drop from a listview to a treeview. Whatever I do does not work and I cannot find...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.