Ich habe das mal nach .Net umgesetzt.
Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential)> _
Public Structure RECT
Public Left As Integer
Public Top As Integer
Public Right As Integer
Public Bottom As Integer
End Structure
Public Class cLockUpdate
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Private Shared Function GetClientRect(ByVal hWnd As System.IntPtr, ByRef _
lpRECT As RECT) As Integer
End Function
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, _
ByVal msg As Integer, _
ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
Private Shared Function RedrawWindow(ByVal hWnd As IntPtr, ByRef lprcUpdate _
As RECT, _
ByVal hrgnUpdate As IntPtr, ByVal flags As Int32) As Int32
End Function
Private Const RDW_INVALIDATE As Int32 = &H1
Private Const WM_SETREDRAW As Int32 = &HB
Private Const RDW_ALLCHILDREN As Int32 = &H80
Private Const RDW_UPDATENOW As Int32 = &H100
Private Const RDW_ERASE As Int32 = &H4
Public Shared Sub LockWindow(ByVal hWnd As IntPtr, ByVal wLock As Boolean)
Dim ClientRect As New RECT
If wLock = True Then
SendMessage(hWnd, WM_SETREDRAW, False, 0&)
Else
SendMessage(hWnd, WM_SETREDRAW, True, 0&)
GetClientRect(hWnd, ClientRect)
RedrawWindow(hWnd, ClientRect, 0&, RDW_ERASE Or _
RDW_INVALIDATE Or RDW_ALLCHILDREN Or RDW_UPDATENOW)
End If
End Sub
End Class Hier ne kleine Testroutine mit einer ListBox
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
Dim sw As New Stopwatch
sw.Start()
cLockUpdate.LockWindow(Me.ListBox1.Handle, True)
For x As Integer = 0 To 50000
Me.ListBox1.Items.Add("Eintrag " & x.ToString)
Next
cLockUpdate.LockWindow(Me.ListBox1.Handle, False)
sw.Stop()
MsgBox("msec: " & sw.ElapsedMilliseconds.ToString)
End Sub
End Class Ohne Lockupdate brauchen die 500.000 Einträge 3 mal solange
Gruß
Gru?
---------------------------------------------------
Snoopy sagt - vb@rchiv find ich gut...
Schon gesehen? OSMMapViewer V2 Control |