Search the Community
Showing results for tags 'virtual listviews'.
-
I got an example from LarsJ's Virtual listviews Virtual listviews Data stored in databases This is very cool code But when I press the scroll next to The program only buffers one data at a time I think this will cause the SERVER to be too busy I want to change into a buffer of 100 items Can someone help me?? database Test3.rar #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <SQLite.au3> ;Opt( "MustDeclareVars", 1 ) Global Const $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo" Global $hLV,$conn Example() Func Example() _SQLite_Startup() ; Check databases Local $iRows3 = CheckDB( "Test3.db" ) Local $iRows ; Create GUI GUICreate( "Virtual ListViews", 850, 400 ) ; Create Tab Local $idTab = GUICtrlCreateTab( 10, 10, 850-20, 400-20 ) GUICtrlCreateTabItem( "Test3.db: " & Format( $iRows3 ) & " rows" ) GUICtrlCreateTabItem( "" ) ; Create ListView Local $idLV = GUICtrlCreateListView( "", 20, 40, 850-40, 400-50, $LVS_OWNERDATA, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) ) $hLV = GUICtrlGetHandle( $idLV ) ; Virtual listview Reduces flicker For $i = 0 To 9 _GUICtrlListView_AddColumn( $hLV, "Col" & $i, 75 ) Next GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" ) GUISetState( @SW_SHOW ) ; Data for first tab $iRows = $iRows3 If $iRows Then _SQLite_Open( "Test3.db" ) GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 ) ; Message loop While 1 Switch GUIGetMsg() Case $idTab If $iRows Then _SQLite_Close( -1 ) Switch GUICtrlRead( $idTab ) Case 0 $iRows = $iRows1 If $iRows Then _SQLite_Open( "Test1.db" ) Case 1 $iRows = $iRows2 If $iRows Then _SQLite_Open( "Test2.db" ) Case 2 $iRows = $iRows3 If $iRows Then _SQLite_Open( "Test3.db" ) EndSwitch GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd If $iRows Then _SQLite_Close( -1 ) _SQLite_Shutdown() GUIDelete() EndFunc Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local Static $tText = DllStructCreate( "wchar[50]" ) Local Static $pText = DllStructGetPtr( $tText ) Local Static $aResult, $iRows, $iFrom Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ) $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ) $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hLV Switch $iCode Case $LVN_GETDISPINFOW Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam ) If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then Local $iIndex = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom + 1 If $iIndex > 0 And $iIndex < $iRows + 1 Then Local $sItem = $aResult[$iIndex][DllStructGetData($tNMLVDISPINFO,"SubItem")] DllStructSetData( $tText, 1, $sItem ) DllStructSetData( $tNMLVDISPINFO, "Text", $pText ) DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) ) EndIf EndIf Case $LVN_ODCACHEHINT Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam ), $iColumns $iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" ) $iTo=DllStructGetData( $tNMLVCACHEHINT, "iTo" ) Local $sSQL = "SELECT * FROM lvdata WHERE item_id >= " & $iFrom & _ " AND item_id <= " & DllStructGetData( $tNMLVCACHEHINT, "iTo" ) & ";" ConsoleWrite($iFrom&" "&$iTo&@CRLF) _SQLite_GetTable2d( -1, $sSQL, $aResult, $iRows, $iColumns ) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func CheckDB( $sDBname ) Local $aRow, $iRows = 0 If FileExists( $sDBname ) Then _SQLite_Open( $sDBname ) _SQLite_QuerySingleRow( -1, "SELECT max(item_id) FROM lvdata;", $aRow ) _SQLite_Close( -1 ) EndIf If IsArray( $aRow ) Then _ $iRows = $aRow[0] + 1 Return $iRows EndFunc Func Format( $iInt ) Return StringRegExpReplace( $iInt, "(\A\d{1,3}(?=(\d{3})+\z)|\d{3}(?=\d))", "\1," ) EndFunc