Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

SetOverlayImage in windows forms ListView

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Ludig - 19 Feb 2007 15:48 GMT
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 ?
Robert Ludig - 20 Feb 2007 13:56 GMT
> 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.ToInt32(), 1,
1);
           int x = SendMessage(this.listView1.Handle.ToInt32(),
0x1000 + 43/*LVM_SETITEMSTATE*/, -1/*all items*/,
((IntPtr)GCHandle.Alloc(item)).ToInt32());
       }

.....

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.