472,371 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

Slow listview

Hi
I am using Listview and inherited listview control overriding WndProc
& PreProcessMessage in ListView.

I need this to customize listview to display only the page the user
scrolls to. Since i am populating listview with more than 200,000
items. It is too slow and tried virtual listview. But that doesnot
allow me to add images in the listview. So now trying to list only the
page user scrolls to.

Tried to keep track of the current page by simple logic. Now want to
know whether is there anyother way of keeping track of the PAGE THE
USER SCROLLS to. I know in advance the number of items in the
listview. Also know the no. of items in each page.

Wot change i need to do to keep track of the current page in
listview??

Also let me know is there any way to speed listview. I tried sorting
to be false and also tried lockwindowupdate api. It had only little
effect. Then also tried virtual listview.. Its performance is very
good but could not add images. Pls let me know how to speeed listview
for nearly 200,000 items(adding images too).

Will this logic of listing the page only the user requested scrolled
to will work (without flickering??)..

using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace CtrPagingListView
{
public class CtrPagingListView : System.Windows.Forms.ListView

{

const int WM_HSCROLL = 0x0114;
const int WM_VSCROLL = 0x0115;
protected const int WM_KEYDOWN = 0x0100;
protected const int VK_LEFT = 0x0025;
protected const int VK_UP = 0x0026;
protected const int VK_RIGHT = 0x0027;
protected const int VK_DOWN = 0x0028;
public int i = 11;
private System.ComponentModel.Container components = null;

// 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 CtrPagingListView()
{
InitializeComponent();

}

protected override void WndProc(ref System.Windows.Forms.Message
msg)
{

int NUMLINES = 5000;

int numLinesPerpage = 12;

if(msg.Msg == WM_HSCROLL)
{System.Windows.Forms.MessageBox.Show("WM_HSCROLL
message","sdf");}

if(msg.Msg == WM_VSCROLL)
{
System.IntPtr param = msg.WParam;
switch ((int)param)
{
case 7:
System.Windows.Forms.MessageBox.Show("SB_BOTTOM message" +
(NUMLINES - numLinesPerpage) + "to" + NUMLINES);
i = NUMLINES - numLinesPerpage;
// nVscrollInc = nVscrollMax - nVscrollPos;
break;

case 0:
//nVscrollInc = -1;
System.Windows.Forms.MessageBox.Show("SB_linwup WM_HSCROLL
message" + i + " to " + (i - 1));
i = i - 1;
break;

case 1:
//nVscrollInc = 1;
System.Windows.Forms.MessageBox.Show("SB_LINEdown message" + i +
"to" + (i + 1));
i = i + 1;
break;

case 2:
// nVscrollInc = min (-1, -cyClient / cyChar);
System.Windows.Forms.MessageBox.Show("SB_PAGEUP message"+ i +
"to" + (i-numLinesPerpage)); i = i-numLinesPerpage;
break;

case 3:
// nVscrollInc = max (1, cyClient / cyChar);
System.Windows.Forms.MessageBox.Show("SB_PAGEDOWN message" + i +
" to " + (i+numLinesPerpage));
i = i+numLinesPerpage;
break;

case 5:
// nVscrollInc = LOWORD (lParam) - nVscrollPos;
System.Windows.Forms.MessageBox.Show("SB_THUMBTRAC K
message","sdf");
break;

}
} base.WndProc(ref msg);
}
protected override void OnMouseUp(MouseEventArgs e)
{
System.Windows.Forms.MessageBox.Show("ONMOusedown" + e.X + " Delta
" + e.Delta);
System.Windows.Forms.MessageBox.Show("ONMOusedown" + e.Y);
base.OnMouseUp(e);
}

public override bool PreProcessMessage(ref
System.Windows.Forms.Message msg)
{
//Convert key code to a .NET Keys structure
// Convert key code to a .NET Keys structure
Keys keyData = ((Keys) (int) msg.WParam) | ModifierKeys;
Keys keyCode = ((Keys) (int) msg.WParam);

// handle message
if (keyData == Keys.Next)
{
System.Windows.Forms.MessageBox.Show("next page" + i + "to" + (i
+ 9));

i = i + 9;
}
else if (keyData == Keys.Prior)
{
System.Windows.Forms.MessageBox.Show("prev message" + i + "to" +
(i - 9));

i = i - 9;

}
else if (keyData == Keys.Up)
{
System.Windows.Forms.MessageBox.Show("UP" + i + "to" +( i - 1));

i = i - 1;
}
else if (keyData == Keys.Down)
{
System.Windows.Forms.MessageBox.Show("DOWN" + i + "to" + (i +
1));
i = i + 1;
}
else if (keyData == Keys.Left)
{
System.Windows.Forms.MessageBox.Show("Left");

}
else if (keyData == Keys.Right)
{
System.Windows.Forms.MessageBox.Show("Right");

} return base.PreProcessMessage(ref msg);
}


}
}
Nov 22 '05 #1
0 1674

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

Similar topics

0
by: Anushya | last post by:
Hi I am using Listview and inherited listview control overriding WndProc & PreProcessMessage in ListView. I need this to customize listview to display only the page the user scrolls to. Since i...
4
by: ?BOT | last post by:
Why is the following code so slow? I have a listView that must refresh it's processes data every 3 seconds. However, this sometimes goes beyond 5 seconds and crashes the application. I have tries...
2
by: cybertof | last post by:
Hello, Is there a solution to the following problem : When filling a listview (30 columns) with around 5000 items, it can take easily 10 sec for the listview to be filled. I have used...
21
by: TryingLikeHeck | last post by:
I have an application that uses a LIstView. Maybe 100 items each with 20 subitems. The app looks at eack item and subitem twice. I.e., it scans the entire set of data item1, sub1,sub2,......
14
by: Marten Van Keer | last post by:
Given two .NET applications A and B. These two application communicate with each other by using an object C: A --> C <-- B Application A has a listview. This listview can be refreshed by...
2
by: johnb41 | last post by:
In my app, I need to open up a multipage tiff file, and also display it's thumbnail images IN HIGH QUALITY. (High Quality meaning anti-aliased, and looking good; not rough and pixely) The...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.