Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SendMessage to Speedup ListView

84 views
Skip to first unread message

Abhay Sobti

unread,
Oct 27, 2006, 7:24:04 AM10/27/06
to
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

unread,
Oct 27, 2006, 8:15:39 AM10/27/06
to
Try
Thisform.LockScreen=.T.

-Anders

"Abhay Sobti" <ab...@stansoftware.com> skrev i meddelandet
news:erJ6czb%23GHA...@TK2MSFTNGP02.phx.gbl...

Jack Jackson

unread,
Oct 27, 2006, 10:16:58 AM10/27/06
to

I don't know about the Listiviw, but with the TreeView setting its
Visible property to .F. speeds it up considerably.

Abhay Sobti

unread,
Oct 28, 2006, 1:34:24 AM10/28/06
to
Tried Visible=.F. , and also LockScreen.
Not much affect

Abhay

"AA" <A@A> wrote in message news:OfEIpGc%23GHA...@TK2MSFTNGP03.phx.gbl...

AA

unread,
Oct 29, 2006, 11:25:56 AM10/29/06
to
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


"Abhay Sobti" <ab...@stansoftware.com> skrev i meddelandet

news:eSy65Ll%23GHA...@TK2MSFTNGP05.phx.gbl...

Samir Ibrahim

unread,
Nov 2, 2006, 2:51:53 AM11/2/06
to
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

"Abhay Sobti" <ab...@stansoftware.com> wrote in message
news:eSy65Ll%23GHA...@TK2MSFTNGP05.phx.gbl...

Abhay Sobti

unread,
Nov 3, 2006, 7:12:16 AM11/3/06
to
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


"Samir Ibrahim" <samir....@wilcopm.com> wrote in message
news:u4OynRl$GHA....@TK2MSFTNGP02.phx.gbl...

Alex.K

unread,
Nov 26, 2006, 9:00:45 PM11/26/06
to
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


Thanks Samir,

thanks anyway

0 new messages