Discussion:
SendMessage to Speedup ListView
(too old to reply)
Abhay Sobti
2006-10-27 11:24:04 UTC
Permalink
Hello Everyone,

I know this is a VB forum, but my question pertains to VFP. I am trying to
stop a ListView from redrawing itself as I am inserting 3000 ListItems.
However, the following code does not prevent it from redrawing. Can you
Help?

Abhay Sobti

#DEFINE WM_SETREDRAW 11

DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam

=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)

** Now I populate the ListBox

=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
AA
2006-10-27 12:15:39 UTC
Permalink
Try
Thisform.LockScreen=.T.

-Anders
Post by Abhay Sobti
Hello Everyone,
I know this is a VB forum, but my question pertains to VFP. I am trying to
stop a ListView from redrawing itself as I am inserting 3000 ListItems.
However, the following code does not prevent it from redrawing. Can you
Help?
Abhay Sobti
#DEFINE WM_SETREDRAW 11
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)
** Now I populate the ListBox
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
Abhay Sobti
2006-10-28 05:34:24 UTC
Permalink
Tried Visible=.F. , and also LockScreen.
Not much affect

Abhay
Post by AA
Try
Thisform.LockScreen=.T.
-Anders
Post by Abhay Sobti
Hello Everyone,
I know this is a VB forum, but my question pertains to VFP. I am trying
to stop a ListView from redrawing itself as I am inserting 3000
ListItems. However, the following code does not prevent it from
redrawing. Can you Help?
Abhay Sobti
#DEFINE WM_SETREDRAW 11
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)
** Now I populate the ListBox
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
AA
2006-10-29 16:25:56 UTC
Permalink
If you're working in VFP you can fill a ListBox control with 3000 AddItem or
AddListItem calls in a loop, times the number of columns, or with a single
line setting RecordSource to a multidimensionsl array or to a cursor.
-Anders
Post by Abhay Sobti
Tried Visible=.F. , and also LockScreen.
Not much affect
Abhay
Post by AA
Try
Thisform.LockScreen=.T.
-Anders
Post by Abhay Sobti
Hello Everyone,
I know this is a VB forum, but my question pertains to VFP. I am trying
to stop a ListView from redrawing itself as I am inserting 3000
ListItems. However, the following code does not prevent it from
redrawing. Can you Help?
Abhay Sobti
#DEFINE WM_SETREDRAW 11
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)
** Now I populate the ListBox
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
Samir Ibrahim
2006-11-02 07:51:53 UTC
Permalink
I have tried this

thisform.listview.visible = .F.
thisform.listview.enable = .F.
* then populate the list view with 100 recoreds * 114 field
thisform.listview.visible = .T.
thisform.listview.enable = .T.

the speed was 2 min 42 sec and after it was 5 sec

Samir ibrahim
Post by Abhay Sobti
Tried Visible=.F. , and also LockScreen.
Not much affect
Abhay
Post by AA
Try
Thisform.LockScreen=.T.
-Anders
Post by Abhay Sobti
Hello Everyone,
I know this is a VB forum, but my question pertains to VFP. I am trying
to stop a ListView from redrawing itself as I am inserting 3000
ListItems. However, the following code does not prevent it from
redrawing. Can you Help?
Abhay Sobti
#DEFINE WM_SETREDRAW 11
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)
** Now I populate the ListBox
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
Abhay Sobti
2006-11-03 12:12:16 UTC
Permalink
Thanks Samir,

Yes ! There is a difference in speed. But my listview has only 3 columns
with 2000 rows. The difference is not really substantial.

thanks anyway
Post by Samir Ibrahim
I have tried this
thisform.listview.visible = .F.
thisform.listview.enable = .F.
* then populate the list view with 100 recoreds * 114 field
thisform.listview.visible = .T.
thisform.listview.enable = .T.
the speed was 2 min 42 sec and after it was 5 sec
Samir ibrahim
Post by Abhay Sobti
Tried Visible=.F. , and also LockScreen.
Not much affect
Abhay
Post by AA
Try
Thisform.LockScreen=.T.
-Anders
Post by Abhay Sobti
Hello Everyone,
I know this is a VB forum, but my question pertains to VFP. I am trying
to stop a ListView from redrawing itself as I am inserting 3000
ListItems. However, the following code does not prevent it from
redrawing. Can you Help?
Abhay Sobti
#DEFINE WM_SETREDRAW 11
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)
** Now I populate the ListBox
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
Jack Jackson
2006-10-27 14:16:58 UTC
Permalink
On Fri, 27 Oct 2006 16:54:04 +0530, "Abhay Sobti"
Post by Abhay Sobti
Hello Everyone,
I know this is a VB forum, but my question pertains to VFP. I am trying to
stop a ListView from redrawing itself as I am inserting 3000 ListItems.
However, the following code does not prevent it from redrawing. Can you
Help?
Abhay Sobti
#DEFINE WM_SETREDRAW 11
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)
** Now I populate the ListBox
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
I don't know about the Listiviw, but with the TreeView setting its
Visible property to .F. speeds it up considerably.
Alex.K
2006-11-27 02:00:45 UTC
Permalink
Samir,


Try this:


Add a BeginUpdate and a EndUpdate Method to the ListView..
Add new properties WasSorted and ViewStyle

in the PROCEDURE BeginUpdate:
WITH THIS
** To try and speed up the loading process:
** 1) Turn off sorting
** 2) Disable the control
** 3) Change the View style to 3 - List
.Visible = .F.
.WasSorted = .Sorted
.Object.Sorted = .F.
.Object.Enabled = .F.
.ViewStyle = .Object.View
.Object.View = lvwList
SendMessage(.hWnd, WM_SETREDRAW, 0, 0)
LockWindowUpdate(.hWnd)
ENDWITH

in the PROCEDURE EndUpdate:
WITH THIS
.Object.Sorted = .WasSorted
.Object.Enabled = .T.
.Object.View = .ViewStyle
SendMessage(.hWnd, WM_SETREDRAW, 1, 0)
LockWindowUpdate(0)
.Visible = .T.
ENDWITH

The issue the following on loading:

Thisform.yourListView.BeginUpdate

-- Load all your items...

Thisform.yourListView.EndUpdate

FYI: In your SendMessage use integer values for boolean

Hope this helps.

- Alex


----- Original Message -----
From: Abhay Sobti
Newsgroups: microsoft.public.fox.vfp.lck-api
Sent: Friday, November 03, 2006 5:12 AM
Subject: Re: SendMessage to Speedup ListView


Thanks Samir,

Yes ! There is a difference in speed. But my listview has only 3 columns
with 2000 rows. The difference is not really substantial.

thanks anyway
Post by Samir Ibrahim
I have tried this
thisform.listview.visible = .F.
thisform.listview.enable = .F.
* then populate the list view with 100 recoreds * 114 field
thisform.listview.visible = .T.
thisform.listview.enable = .T.
the speed was 2 min 42 sec and after it was 5 sec
Samir ibrahim
Post by Abhay Sobti
Tried Visible=.F. , and also LockScreen.
Not much affect
Abhay
Post by AA
Try
Thisform.LockScreen=.T.
-Anders
Post by Abhay Sobti
Hello Everyone,
I know this is a VB forum, but my question pertains to VFP. I am trying
to stop a ListView from redrawing itself as I am inserting 3000
ListItems. However, the following code does not prevent it from
redrawing. Can you Help?
Abhay Sobti
#DEFINE WM_SETREDRAW 11
DECLARE INTEGER SendMessage IN user32 INTEGER hWnd,;
INTEGER Msg,;
INTEGER wParam,;
INTEGER lParam
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.T.,0)
** Now I populate the ListBox
=SendMessage(THIS.Lv.hWnd, WM_SETREDRAW ,.F.,0)
Loading...