469,081 Members | 1,428 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,081 developers. It's quick & easy.

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 1428

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Anushya | last post: by
4 posts views Thread by ?BOT | last post: by
2 posts views Thread by cybertof | last post: by
21 posts views Thread by TryingLikeHeck | last post: by
14 posts views Thread by Marten Van Keer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.