473,657 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Diagnost ics;

namespace Microsoft.Sampl es.VirtualListV iew
{
#region VirtualListView Delegates
public delegate void QueryItemTextHa ndler(int item, int subItem,
out string text);
public delegate void QueryItemImageH andler(int item, int subItem,
out int imageIndex);
public delegate void QueryItemIndent Handler(int item, out int
itemIndent);
#endregion

/// <summary>
/// Summary description for VirtualListView Control.
/// </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)ListViewMe ssages.LVM_SETI TEMCOUNT,
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.CreatePar ams
CreateParams {
get {
CreateParams cp = base.CreatePara ms;
// LVS_OWNERDATA style must be set when the control is
created
cp.Style |= (int)ListViewSt yles.LVS_OWNERD ATA;
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 ArgumentExcepti on("Icon views are
invalid for virtual ListViews", "View");
}
base.View = value;
}
}

#region Display query callbacks
public event QueryItemTextHa ndler QueryItemText;
public event QueryItemImageH andler QueryItemImage;
public event QueryItemIndent Handler QueryItemIndent ;
#endregion

void OnDispInfoNotic e(ref Message m, bool useAnsi) {

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

if((info.item.m ask & (uint)ListViewI temMask.LVIF_TE XT) >
0) {
if (QueryItemText != null) {
QueryItemText(i nfo.item.iItem, info.item.iSubI tem,
out lvtext);
if (lvtext != null) {
try {
int maxIndex = Math.Min(info.i tem.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(d ata, 0,
info.item.pszTe xt, data.Length);
}
catch (Exception e) {
Debug.WriteLine ("Failed to copy text name
from client: " + e.ToString(), "VirtualListVie w.OnDispInfoNot ice");
}
}
}
}

if((info.item.m ask & (uint)ListViewI temMask.LVIF_IM AGE) >
0) {
int imageIndex = 0;
if (QueryItemImage != null) {
QueryItemImage( info.item.iItem ,
info.item.iSubI tem, out imageIndex);
}
info.item.iImag e = imageIndex;
}

if ((info.item.mas k & (uint)ListViewI temMask.LVIF_IN DENT)
0) {

int itemIndent = 0;
if (QueryItemInden t != null) {
QueryItemIndent (info.item.iIte m, out itemIndent);
}
info.item.iInde nt = itemIndent;
}
m.Result = new IntPtr(0);
}
protected override void WndProc(ref
System.Windows. Forms.Message m) {
NMHDR nm1;
bool messageProcesse d = false;
switch (m.Msg) {
case (int)WindowsMes sage.WM_REFLECT +
(int)WindowsMes sage.WM_NOTIFY:
nm1 = (NMHDR) m.GetLParam(typ eof(NMHDR));
switch(nm1.code ) {
case (int)ListViewNo tices.LVN_GETDI SPINFOW:
OnDispInfoNotic e(ref m, false);
messageProcesse d = true;
break;
default:
break;
}
break;
default:
break;
}
if (!messageProces sed) {
base.WndProc(re f m);
}
}
}
}
Jul 21 '05 #1
0 1612

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

Similar topics

11
8887
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 enlarged one by one). This topic seems to be frequent. Some says that you under no circumstances can protect your images, others seem to have preventing solutions.
13
6121
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. However, in my design I need them to be laid out like this: XXXXXXXXooooooooo XXXXXXXXooooooooo XXXXXXXXooooooooo XXXXXXXXLLLLLLLLL
4
4150
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. I am trying to create an absolute reference to these images so I don't have to make the same include for different directories. What is the best way to do this? Thanks.
2
4221
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 NetAdvantage component suite from Infragistics for my web applications. When installing they create several virtual
3
3820
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 nutshell when testing my ASP.NET (localhost) apps images randomly don't load on the page. Examining the IIS logfile shows the missing images give 401 or 403 errors. Here's an example - 10:15:47 127.0.0.1 GET...
5
2725
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
280
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 QueryItemText.. And text alone is working fine.. using System; using System.Windows.Forms; using System.Diagnostics;
12
3850
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 like <a href="../../Search/page.aspx">, everything works fine as long as I publish the site to a root web like http://localhost. However, I am developing on my local C drive in c:\development\project. I
3
1833
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 example http://root.com/images/some.gif in my source is just /images/some.gif. When I publish to the root web on any IIS server, that works just fine. On my old XP machine I had registered a custom version of multisite.dll with a config.ini like...
0
8312
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
8827
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
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8606
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...
1
6169
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
5632
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();...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
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.