PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: WinFBE - 2.0.2 - ListView  (Read 577 times)

SeaVipe

  • Senior Member
  • ***
  • Posts: 277
  • Windows 10
Re: WinFBE - 2.0.2 - ListView
« Reply #15 on: January 09, 2020, 01:21:19 PM »

Hi Paul,
(Using the 2 files you posted yesterday)
This line compiles okay, but has no effect:
Code: [Select]
frmMainJ.lvJournal.OddRowColorEnabled = False
The more text in the ListView, the longer the refresh.
With all of the following code removed, the average refresh is about 60ms, added back in, the refresh ranges between 2500ms and 6500ms.
Here is that code:
Code: [Select]

Sub set_row_colour( ByRef ListView as wfxListView, ByVal fg as COLORREF, ByVal bg as COLORREF, ByVal ubRow as UByte, ByVal caller As String = "Unknown" )
    With ListView
        For iCol as Long = 0 to 5
            .Item( ubRow ).SubItem( iCol ).ForeColor = fg '' <-- Comment out this line and the refresh time is about 70ms
        Next iCol
    End With
End Sub
''
''
Sub do_colour_event_types( ByRef ListView as wfxListView, ByVal this_type as Long, ByVal caller As String = "Unknown" )
    '? "do_colour_event_types"; caller
    For i as Integer = 1 to 30
        If js( jdb.RecPtr ).Entry_Type( i ) = this_type OrElse js( jdb.RecPtr ).Entry_Category( i ) = this_type then
            '' User select
            set_row_colour( ListView, colors.Blue, 0 , i - 1 )           
        ElseIf js( jdb.RecPtr ).Entry_Type( i ) =  jdb.Entry_Modifier( "Done" ) OrElse js( jdb.RecPtr ).Entry_Category( i ) = jdb.Entry_Modifier( "Done" ) then           
            set_row_colour( ListView, colors.Gray, 0 , i - 1 )           
        ElseIf js( jdb.RecPtr ).Entry_Type( i ) =  jdb.Entry_Modifier( "Daily" ) OrElse js( jdb.RecPtr ).Entry_Category( i ) = jdb.Entry_Modifier( "Daily" ) then           
            set_row_colour( ListView, colors.DarkRed , 0 , i - 1 )   
        Else
            set_row_colour( ListView, colors.SystemWindowText, 0 , i - 1 )           
        End If
    Next i
    '' Refresh is only required to display colour changes if

    '' wfxListView.inc, AfxRedrawWindow(this.hWindow) is commented out.
    'If IsWindowVisible( ListView.hWindow ) Then '' Required?
        ' ListView.Refresh
    'End If
End Sub
I hope this is helpful.
« Last Edit: January 09, 2020, 01:27:07 PM by SeaVipe »
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 8974
  • Windows 10
    • PlanetSquires Software
Re: WinFBE - 2.0.2 - ListView
« Reply #16 on: January 09, 2020, 05:13:09 PM »

Hi Clive, I am not at my development computer but looking at your code that you posted I don't see BeginUpdate / EndUpdate code as part of your routines. To speed up the recolor I expect that if you change your do_colour_event_types function to the following then it should be a lot faster:

Code: [Select]
Sub do_colour_event_types( ByRef ListView as wfxListView, ByVal this_type as Long, ByVal caller As String = "Unknown" )
    '? "do_colour_event_types"; caller
    ListView.BeginUpdate

    For i as Integer = 1 to 30
        If js( jdb.RecPtr ).Entry_Type( i ) = this_type OrElse js( jdb.RecPtr ).Entry_Category( i ) = this_type then
            '' User select
            set_row_colour( ListView, colors.Blue, 0 , i - 1 )           
        ElseIf js( jdb.RecPtr ).Entry_Type( i ) =  jdb.Entry_Modifier( "Done" ) OrElse js( jdb.RecPtr ).Entry_Category( i ) = jdb.Entry_Modifier( "Done" ) then           
            set_row_colour( ListView, colors.Gray, 0 , i - 1 )           
        ElseIf js( jdb.RecPtr ).Entry_Type( i ) =  jdb.Entry_Modifier( "Daily" ) OrElse js( jdb.RecPtr ).Entry_Category( i ) = jdb.Entry_Modifier( "Daily" ) then           
            set_row_colour( ListView, colors.DarkRed , 0 , i - 1 )   
        Else
            set_row_colour( ListView, colors.SystemWindowText, 0 , i - 1 )           
        End If
    Next i

    ListView.EndUpdate

    '' Refresh is only required to display colour changes if

    '' wfxListView.inc, AfxRedrawWindow(this.hWindow) is commented out.
    'If IsWindowVisible( ListView.hWindow ) Then '' Required?
        ' ListView.Refresh
    'End If
End Sub
Logged
Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

SeaVipe

  • Senior Member
  • ***
  • Posts: 277
  • Windows 10
Re: WinFBE - 2.0.2 - ListView
« Reply #17 on: January 09, 2020, 05:14:00 PM »

Hi Paul,
In my code,  BeginUpdate and EndUpdate are throwing Error 6, There are 2 ListView controls on a form and regardless of whether or not there is any code between BeginUpdate and EndUpdate an error 6 is thrown for each ListView, but, it doesn't invoke the error handler. Print GetLastError() catches the error (and clears it).
Code: [Select]

With frmMainJ.lvEntryType       
        .BeginUpdate
        .Items.Clear '' Leave here, faster update.       
        For i As Integer = LBound( accumulator ) To UBound( accumulator )   
            j = .Items.Add( Left( accumulator( i ), 10 ) )
            Dim As String s = Mid(  accumulator( i ), 12, 50 )
            .Item( j ).SubItems.Add( s )
            Print GetLastError() ' prints 6 once per loop
        Next i
        .EndUpdate
End with
Comment out BeginUpdate and EndUpdate results in no error but refresh is slow.
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill

SeaVipe

  • Senior Member
  • ***
  • Posts: 277
  • Windows 10
Re: WinFBE - 2.0.2 - ListView
« Reply #18 on: January 09, 2020, 05:25:11 PM »

Thanks, Paul,
Perfect, BeginUpdate and EndUpdate worked in do_colour_event_types without error 6 and was very fast. However, BeginUpdate and EndUpdate are still throwing error 6 in the code that adds rows and cols.
Logged
Clive Richey
There is nothing government can give you that it hasn't already taken from you in the first place. Winston Churchill
Pages: 1 [2]