473,473 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 6451
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.