473,396 Members | 2,029 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,396 software developers and data experts.

add images to virtual list

Hi
I am trying to add image items to listview. Here how to handle if i
need to add images?? Pls go thru the code.

In the form where i have used this virtualListView, have handled
QueryItemText.. And text alone is working fine..

using System;
using System.Windows.Forms;
using System.Diagnostics;

namespace Microsoft.Samples.VirtualListView
{
#region VirtualListView Delegates
public delegate void QueryItemTextHandler(int item, int subItem,
out string text);
public delegate void QueryItemImageHandler(int item, int subItem,
out int imageIndex);
public delegate void QueryItemIndentHandler(int item, out int
itemIndent);
#endregion

/// <summary>
/// Summary description for VirtualListViewControl.
/// </summary>
public class VirtualListView : ListView {
// store the item count to prevent the call to
SendMessage(LVM_GETITEMCOUNT)
private int itemCount = 0;
public int ItemCount {
get { return itemCount; }
set {
itemCount = value;
int result;
result = WindowsFunction.SendMessage(
this.Handle,
(int)ListViewMessages.LVM_SETITEMCOUNT,
itemCount,
0);
}
}

public VirtualListView ()
{
// virtual listviews must be Details or List view with no
sorting
View = View.Details;
Sorting = SortOrder.None;
}

protected override System.Windows.Forms.CreateParams
CreateParams {
get {
CreateParams cp = base.CreateParams;
// LVS_OWNERDATA style must be set when the control is
created
cp.Style |= (int)ListViewStyles.LVS_OWNERDATA;
return cp;
}
}

public new System.Windows.Forms.View View {
get {
return new System.Windows.Forms.View();
}
set {
if (value == View.LargeIcon ||
value == View.SmallIcon) {
throw new ArgumentException("Icon views are
invalid for virtual ListViews", "View");
}
base.View = value;
}
}

#region Display query callbacks
public event QueryItemTextHandler QueryItemText;
public event QueryItemImageHandler QueryItemImage;
public event QueryItemIndentHandler QueryItemIndent;
#endregion

void OnDispInfoNotice(ref Message m, bool useAnsi) {

LVDISPINFO info =
(LVDISPINFO)m.GetLParam(typeof(LVDISPINFO));
string lvtext = null;

if((info.item.mask & (uint)ListViewItemMask.LVIF_TEXT) >
0) {
if (QueryItemText != null) {
QueryItemText(info.item.iItem, info.item.iSubItem,
out lvtext);
if (lvtext != null) {
try {
int maxIndex = Math.Min(info.item.cchTextMax-1, lvtext.Length);
char[] data = new char[maxIndex+1];
lvtext.CopyTo(0, data, 0, lvtext.Length);
data[maxIndex] = '\0';
System.Runtime.InteropServices.Marshal.Copy(data, 0,
info.item.pszText, data.Length);
}
catch (Exception e) {
Debug.WriteLine("Failed to copy text name
from client: " + e.ToString(), "VirtualListView.OnDispInfoNotice");
}
}
}
}

if((info.item.mask & (uint)ListViewItemMask.LVIF_IMAGE) >
0) {
int imageIndex = 0;
if (QueryItemImage != null) {
QueryItemImage(info.item.iItem,
info.item.iSubItem, out imageIndex);
}
info.item.iImage = imageIndex;
}

if ((info.item.mask & (uint)ListViewItemMask.LVIF_INDENT)
0) {

int itemIndent = 0;
if (QueryItemIndent != null) {
QueryItemIndent(info.item.iItem, out itemIndent);
}
info.item.iIndent = itemIndent;
}
m.Result = new IntPtr(0);
}
protected override void WndProc(ref
System.Windows.Forms.Message m) {
NMHDR nm1;
bool messageProcessed = false;
switch (m.Msg) {
case (int)WindowsMessage.WM_REFLECT +
(int)WindowsMessage.WM_NOTIFY:
nm1 = (NMHDR) m.GetLParam(typeof(NMHDR));
switch(nm1.code) {
case (int)ListViewNotices.LVN_GETDISPINFOW:
OnDispInfoNotice(ref m, false);
messageProcessed = true;
break;
default:
break;
}
break;
default:
break;
}
if (!messageProcessed) {
base.WndProc(ref m);
}
}
}
}
Jul 21 '05 #1
0 1555

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

Similar topics

11
by: LarryM | last post by:
Hi, NB, not to stop capturing the single displayed Image, but to stop downloading the entire image directory. (In my Website you will do a search, and get some thumbnails, and these can be...
13
by: DM | last post by:
If I put three images next to each other (each within an anchor tag) they all line up horizontally as expected with no space between them. I.e., they're sitting flush up against each other. ...
4
by: Rob | last post by:
I have a web project that has multiple directories. Some of the files in different directories use the same include files. The problem is that these include files also reference an image folder. ...
2
by: Jeffry van de Vuurst | last post by:
Hi, (sorry for the crosspost, I wasn't sure which was the best place to put this). I was just thinking about something and wondered if any of you has some ideas about this. I'm using the...
3
by: Simon | last post by:
This problem has been driving me mad for months.... Seen a few posts on forums about it but no answers... No mention on MSDN etc. XP Pro SP1, VS.NET (c#) .Net framework 1.1, IIS 5.1. In a...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
0
by: Anushya | last post by:
Hi I am trying to add image items to listview. Here how to handle if i need to add images?? Pls go thru the code. In the form where i have used this virtualListView, have handled...
12
by: John Kotuby | last post by:
Hi all, Maybe this is a simple problem found in ASP.NET 2.0 course 101, but I must have missed it. When I create a page in Visual Web Developer and use URLs like "/images/picture.gif " or a link...
3
by: John Kotuby | last post by:
I have just upgraded to a new development machine that came with Vista ultimate. I am developing a website with VS2005 and VB. My image and css references in my source code are all relative. For...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
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...

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.