Results 1 to 6 of 6

Thread: LockWindowUpdate API Problem...

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Angry LockWindowUpdate API Problem...

    OK, I am using the following...
    VB Code:
    1. Private Declare Function LockWindowUpdate Lib "user32" Alias "LockWindowUpdate" (ByVal hwndLock As Long) As Long
    2.  
    3. Private Sub LoadData
    4.    ListView1.ListItems.Clear
    5.    DoEvents
    6.    LockWindowUpdate ListView1.hWnd
    7.    'Load data code, to big and irrelavant to post here :D
    8.    LockWindowUpdate False
    9. 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!
    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"...???

  2. #2

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Angry 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

  3. #3
    Addicted Member shagratt's Avatar
    Join Date
    Jul 2019
    Location
    Argentina
    Posts
    203

    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

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    6,190

    Re: LockWindowUpdate API Problem...

    Quote Originally Posted by shagratt View Post
    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>

  5. #5
    PowerPoster
    Join Date
    Mar 2005
    Posts
    2,943

    Re: LockWindowUpdate API Problem...

    Quote Originally Posted by wqweto View Post
    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.

  6. #6
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    617

    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

    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
    Last edited by Episcopal; Dec 17th, 2019 at 08:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width