Results 1 to 5 of 5

Thread: [RESOLVED] Listview SetRedraw

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    61

    Resolved [RESOLVED] Listview SetRedraw

    Thru testing I have found that VB's Listviews do not respond to
    to WM_SetRedraw. So I have been trying to get this code to work.
    As noted the FindWindowEx call always returns zero.
    Just hoping someone can provide some insight.
    'common controls v6

    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
    Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" _
        (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
        
    Sub SetRedraw(ByVal LV As ListView, ByVal nState As Long) 'nState 1 or 0
     Dim hWndLV As Long
     hWndLV = FindWindowEx(LV.hWnd, 0&, "ListView20WndClass", vbNullString)  'from WinSpy
     Debug.Print hWndLV                  'always zero
     SendMessage hWndLV, WM_SETREDRAW, nState, ByVal 0&
    End Sub

  2. #2
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    7,219

    Re: Listview SetRedraw

    I have done some subclassing of the ListView control, and have dealt with refreshing it in the past. However, I'd do better if you just outlined what you're actually trying to do (at a higher level).
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    61

    Re: Listview SetRedraw

    Thanks Elroy, i'm just trying to speed up Listview loading.
    I have used LockWindowUpdate and it seems to work, but MS says not
    to use it, but rather use WM_SetRedraw.

    I know there are other methods, LVM_SetItemCount, which I use. Also
    setting Enabled to False, Sorting Off while loading, etc

    Also, Krool's LV control has Redraw On/Off, but that LV is created using
    CreateWindowEx, i.e. SysListVew32 class.

    Would be interested in seeing your subclassing method.

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    7,219

    Re: Listview SetRedraw

    Here's (attached) a small project using the ListView in MsComCtl.ocx (the VB6 ListView), and subclassing it.

    I'm not sure it'll do you much good though. Here's a link to Krool's ListView, with the source code peeled out such that you only get his ListView. You'd probably be better off looking through his code and how he does things, as he's having to deal with everything, including refreshes.

    p.s. If you grab Krool's ListView, please be sure and read the post #1 in that thread, especially the steps making sure you've got the OLEGuids.tlb typelib setup correctly.
    Attached Files Attached Files
    Last edited by Elroy; Nov 27th, 2021 at 12:17 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2016
    Location
    Texas panhandle
    Posts
    61

    Re: Listview SetRedraw

    Tnanks again Elroy. Studying your code.
    I've finally given up on the code in my original post.
    The class "ListView20WndClass" is still a vb listview
    just like Thunder Controls, So it can never get at the
    class "SysListView32".

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