LockWindowUpdate API Problem...
OK, I am using the following...
VB Code:
Private Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long
Private Sub LoadData
ListView1.ListItems.Clear
DoEvents
LockWindowUpdate ListView1.hWnd
'Load data code, to big and irrelavant to post here :D
LockWindowUpdate False
End Sub
Now this works fine. The ListView does not update till all items have been added, which speeds the application up. This is what I want...HOWEVER, if while loading I select another form, which makes it active, from the same application the ListView becomes "UnLocked"! And the user can see the items being added! :mad:
How can I get around this?
Wokawooooo
I understand that you can lock only one window at a time, but the only window I lock in my app is the ListView. Why does it get "Unlocked"...???
:confused:
Oh large sloppy poo on a very big stick!
After further investigation, it only requires a user to select any other application, related or not, and the ListView becomes unlocked! Arrrrrr.....bugger! :(
akoW
Re: LockWindowUpdate API Problem...
Old post, but my solution with grids /combos is to make them invisible and then visible again at the end of the loading function
Re: LockWindowUpdate API Problem...
Quote:
Originally Posted by
shagratt
Old post, but my solution with grids /combos is to make them invisible and then visible again at the end of the loading function
Making a control invisible forces it to lose focus. You can try using WM_SETREDRAW to suppress redraws instead:
Code:
Private Const WM_SETREDRAW As Long = &HB
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Property Let HwndRedraw(ByVal hWnd As Long, ByVal bValue As Boolean)
Call SendMessage(hWnd, WM_SETREDRAW, -bValue, ByVal 0)
End Property
cheers,
</wqw>
Re: LockWindowUpdate API Problem...
Quote:
Originally Posted by
wqweto
Making a control invisible forces it to lose focus. You can try using WM_SETREDRAW to suppress redraws instead:
Code:
Private Const WM_SETREDRAW As Long = &HB
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Property Let HwndRedraw(ByVal hWnd As Long, ByVal bValue As Boolean)
Call SendMessage(hWnd, WM_SETREDRAW, -bValue, ByVal 0)
End Property
cheers,
</wqw>
HI BRO!
I have no idea to use your tips...
can you post a simple whe the listview is filled?
Tks.
Re: LockWindowUpdate API Problem...
Private Declare Function RedrawWindow _
Lib "user32.dll" (ByVal hWnd As Long, _
ByVal lprcUpdate As Long, _
ByVal hrgnUpdate As Long, _
ByVal fuRedraw As Long) As Long
Quote:
Private Sub LoadData
ListView1.ListItems.Clear
DoEvents
Call FreezeWindow (ListView1.hWnd, True)
'Load data code, to big and irrelavant to post here
Call FreezeWindow (ListView1.hWnd, False)
End Sub
Code:
Private Sub FreezeWindow(ByVal hWnd As Long, Optional ByVal boolAction As Boolean = True)
Const WM_SETREDRAW As Long = &HB&
Const RDW_ALLCHILDREN As Long = &H80
Const RDW_INVALIDATE As Long = &H1
If boolAction = True Then
SendMessage hWnd, WM_SETREDRAW, False, 0&
Else
SendMessage hWnd, WM_SETREDRAW, True, 0&
RedrawWindow hWnd, ByVal 0&, 0&, RDW_INVALIDATE Or RDW_ALLCHILDREN
End If
End Sub