What should I do if my VB control is flickering?

Here's the code:

' Must SetWindowPos API
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOREDRAW = &H8
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOZORDER = &H4
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H80
Private Sub showWindow(ByVal h As Long, ByVal bShow As Boolean)
If (Not bShow) Then
SetWindowPos h, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_HIDEWINDOW Or SWP_NOREDRAW
Else
SetWindowPos h, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_SHOWWINDOW Or SWP_FRAMECHANGED
End If
End Sub
Sample:
showWindow List1.hwnd, False
With List1
.BeginUpdate
With .Items
.Add "Item 1"
.Add "Item 2"
.............
.Add "Item n"
End With
.EndUpdate
End With
showWindow List1.hwnd, True
view raw flickering.vb hosted with ❤ by GitHub

Komentar