473,804 Members | 3,250 Online
Bytes | Software Development & Data Engineering Community
+ 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 6483
On 19 Feb., 16:48, "Robert Ludig" <schwertfischtr omb...@gmx.dewr ote:
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(La youtKind.Sequen tial)]
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("comc tl32.dll")]
public extern static bool ImageList_SetOv erlayImage(int himl,
int iImage, int iOverlay);
[DllImport("user 32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int
wParam, int lParam);
public Form1()
{
InitializeCompo nent();
}
private void Form1_Load(obje ct sender, EventArgs e)
{
listView1.Items .Add("aa", 0);
}
private void button1_Click(o bject sender, EventArgs e)
{
LVITEM item = new LVITEM();
item.stateMask = 0x0F00; /*LVIS_OVERLAYMA SK*/
item.state = 1 << 8 /*INDEXTOOVERLAY MASK(1)*/;
ImageList_SetOv erlayImage(imag eList1.Handle.T oInt32(), 1,
1);
int x = SendMessage(thi s.listView1.Han dle.ToInt32(),
0x1000 + 43/*LVM_SETITEMSTA TE*/, -1/*all items*/,
((IntPtr)GCHand le.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
3918
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. now use task manager to see the GDI usage of the process. everything seems normal. now catch the ListView's scroller and start to move it downwards. you have to hold the constant speed so that the ListView is constantly repainted. look at the...
2
7851
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 in treeview i display the content item in axWebBrowser, i close the sub form normally when i close the main the following error is generated An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll ...
2
1841
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 inherited user control ...", then I browser to c:\winnt\microsoft.net\framework\v1.1.4322\system.windows.forms.dll
0
350
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 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 ?
2
3750
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 listview1 to listview2, only the text does. Both listviews have their smallimagelist as the single imagelist I have. Here is my code and thank you for any help. private void listView1_ItemDrag(object sender, ItemDragEventArgs e) { int max =...
0
1898
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 form every thing works fine: checking items by code as well as checking with mouse: Using the CheckdItems Property is confused too.
2
6834
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 form every thing works fine: checking items by code
2
2450
by: win | last post by:
The SortKey of VB6 is not in .Net. Can I still do sorting using a listview? Thanks
1
1950
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 any good articals on the net on how to do so. I have attached my original code for the two treeview controls. Can anybody point out where I need to make changes? Dim NewNode As Windows.Forms.TreeNode Dim imgIndex As Windows.Forms.TreeNode...
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9588
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10589
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7625
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.