|
-
March 22nd, 2001, 08:54 PM
#1
listbox Refresh?
how do I keep a listbox from refreshing till I have filled it. If I hide the form. It is much faster.
-
March 23rd, 2001, 06:19 AM
#2
Re: listbox Refresh?
If you add items to a listbox using it's Add method it always refreshes the list.
You can add items using the API which is fatser and in that case you can call LockWindowsUpdate() to prevent the listbox refreshing until it is full. Then call UpdateWindow() to refresh it all.
The api declarations are:
Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (byval hwndLock as Long) as Long
Declare Function UpdateWindow Lib "user32" Alias "UpdateWindow" (byval hwnd as Long) as Long
HTH,
Duncan
-------------------------------------------------
Ex. Datis: Duncan Jones
Merrion Computing Ltd
http://www.merrioncomputing.com
-
March 23rd, 2001, 09:14 AM
#3
Re: listbox Refresh?
This is a code sample from MSDN. Add two List Box controls and a command button on the form. You can select items from the first List Box by Double clicking them. Each selected item will be added to the second List Box control and will be shown when you click the command button.
private Const WM_SetRedraw = &HB
private Const LB_ADDSTRING = &H401
private Declare Function SendMessage Lib "User" (byval hWnd as Integer, byval wMsg as _
Integer, byval wParam as Integer, lParam as Any) as Integer
private Declare Function SendMessageByString Lib "User" Alias "PostMessage" (byval hWnd _
as Integer, byval wMsg as Integer, byval wParam as Integer, byval lParam as _
string) as Integer
Sub Form_Load()
Dim X as Integer
Dim D as Integer
Dim S as string
'Add some dummy data to List1
for X = 0 to 15
List1.AddItem "Item #" + Str$(X)
next X
End Sub
Sub Command1_Click()
'Show updated list box now
X = SendMessage(List2.hWnd, WM_SetRedraw, 1, 0)
End Sub
Sub List1_DblClick()
'Disable the Repaint event
X = SendMessage(List2.hWnd, WM_SetRedraw, 0, 0)
S = List1.List(List1.ListIndex)
' Must use SendMessageByString instead of
' List2.AddItem S to prevent redrawing
D = SendMessageByString(List2.hWnd, LB_ADDSTRING, 0, S)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|