PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Jean-pierre Leroy on October 24, 2012, 09:29:58 AM

Title: Any simple way to disable LVN_ITEMCHANGED at run-time ?
Post by: Jean-pierre Leroy on October 24, 2012, 09:29:58 AM
Dear FF users,

The LVN_ITEMCHANGED notification is very useful to update in the status-bar the number of lines selected by a user in a ListView control.


'--------------------------------------------------------------------------------
Function TASKS_TASKSLV_LVN_ITEMCHANGED ( _
                                     ControlIndex  As Long,            _  ' index in Control Array
                                     hWndForm      As Dword,           _  ' handle of Form
                                     hWndControl   As Dword,           _  ' handle of Control
                                     ByVal lpNMV   As NM_LISTVIEW Ptr  _  ' pointer to NM_LISTVIEW
                                     ) As Long

    ' update the number of selected lines
    FF_StatusBar_SetText(HWND_TASKS_STATUSBAR, 1, Format$(ListView_GetSelectedCount(HWND_TASKS_TASKSLV))+" line(s) selected")

End Function


But this code below cause the status-bar to flicker when I initially load the ListView with thousands of lines.

So here is my question: Is there a way to disable temporarily the LVN_ITEMCHANGED notification, when I load data in a Listview control to avoid the status bar to flicker ?

Any ideas ? Thanks,
Jean-Pierre

Title: Re: Any simple way to disable LVN_ITEMCHANGED at run-time ?
Post by: Pat Dooley on October 24, 2012, 10:42:10 AM
Could you FF_Control_ShowState( HWND_FORM1_STATUSBAR, %SW_HIDE ) the statusbar prior to loading the
listview and then FF_Control_ShowState( HWND_FORM1_STATUSBAR, %SW_SHOW )
when loading complete?
This is not what you are after, but it avoids flicker.

Title: Re: Any simple way to disable LVN_ITEMCHANGED at run-time ?
Post by: José Roca on October 24, 2012, 10:54:19 AM
You can disable redrawing with
SendMessage HWND_TASKS_STATUSBAR, %WM_SETREDRAW, %FALSE, 0
before loading the items and enable it later with
SendMessage HWND_TASKS_STATUSBAR, %WM_SETREDRAW, %TRUE, 0
Title: Re: Any simple way to disable LVN_ITEMCHANGED at run-time ?
Post by: Jean-pierre Leroy on October 24, 2012, 06:11:26 PM
Pat, Jose,

Thanks a lot for your ideas; I'll give them a try.

Jean-Pierre

Title: Re: Any simple way to disable LVN_ITEMCHANGED at run-time ?
Post by: Paul Squires on October 24, 2012, 09:41:08 PM
Create a global variable, say, "gAllowNotifications". Set it to TRUE only after all of your listview items have loaded.

'--------------------------------------------------------------------------------
Function TASKS_TASKSLV_LVN_ITEMCHANGED ( _
                                     ControlIndex  As Long,            _  ' index in Control Array
                                     hWndForm      As Dword,           _  ' handle of Form
                                     hWndControl   As Dword,           _  ' handle of Control
                                     ByVal lpNMV   As NM_LISTVIEW Ptr  _  ' pointer to NM_LISTVIEW
                                     ) As Long

   If IsFalse(gAllowNotifications) Then Exit Function

    ' update the number of selected lines
    FF_StatusBar_SetText(HWND_TASKS_STATUSBAR, 1, Format$(ListView_GetSelectedCount(HWND_TASKS_TASKSLV))+" line(s) selected")

End Function