You'll not get anything faster than this:
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
;#AutoIt3Wrapper_UseX64=y
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <SQLite.au3>
Opt( "MustDeclareVars", 1 )
Global $pTable, $iCols, $hLV
Example()
Func Example()
_SQLite_Startup()
_SQLite_Open( "random_data.db" )
Local $iRows
Local $sSQL = "SELECT * FROM RandomData;"
_SQLite_GetTableEx( -1, $sSQL, $pTable, $iRows, $iCols )
$pTable += $iCols * ( @AutoItX64 ? 8 : 4 )
GUICreate( "Virtual ListView", 1650, 800 )
Local $idLV = GUICtrlCreateListView( "", 10, 10, 1650-20, 800-20, $LVS_OWNERDATA, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) )
$hLV = GUICtrlGetHandle( $idLV ) ; Virtual listview Reduces flicker
For $i = 0 To $iCols - 1
_GUICtrlListView_AddColumn( $idLV, "Col" & $i, 160 )
Next
GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 )
GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )
GUISetState( @SW_SHOW )
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
$pTable -= $iCols * ( @AutoItX64 ? 8 : 4 )
_SQLite_FreeTable( $pTable )
_SQLite_Close()
_SQLite_Shutdown()
EndFunc
Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam )
Static $iPtrSize = @AutoItX64 ? 8 : 4, $hDLL = DllOpen( "kernel32.dll" ), $aDisplay[100][$iCols], $iFrom, $iTo
Static $tText = DllStructCreate( "wchar[4094]" ), $pText = DllStructGetPtr( $tText )
Static $tagNMLVCACHEHINT = $tagNMHDR & ";int iFrom;int iTo"
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 Not BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), 1 ) Then Return ; 1 = $LVIF_TEXT
Local $iItem = DllStructGetData( $tNMLVDISPINFO, "Item" ) - $iFrom
If $iItem < 0 Or $iItem > $iTo - $iFrom Then Return
Local $iSubItem = DllStructGetData($tNMLVDISPINFO,"SubItem")
Local $sItem = $aDisplay[$iItem][$iSubItem]
Local $l = StringLen( $sItem )
DllStructSetData( $tText, 1, $sItem )
DllStructSetData( $tNMLVDISPINFO, "Text", $pText )
DllStructSetData( $tNMLVDISPINFO, "TextMax", ( $l <= 4094 ? $l : 4094 ) )
Return
Case $LVN_ODCACHEHINT
Local $tNMLVCACHEHINT = DllStructCreate( $tagNMLVCACHEHINT, $lParam )
$iFrom = DllStructGetData( $tNMLVCACHEHINT, "iFrom" )
$iTo = DllStructGetData( $tNMLVCACHEHINT, "iTo" )
Local $pFrom, $pStr, $iLen, $tWstr
For $i = $iFrom To $iTo
$pFrom = $pTable + $i * $iCols * $iPtrSize
For $j = 0 To $iCols - 1
$pStr = DllStructGetData( DllStructCreate( "ptr", $pFrom + $j * $iPtrSize ), 1 )
$iLen = DllCall( $hDLL, "int", "MultiByteToWideChar", "uint", 65001, "dword", 0, "ptr", $pStr, "int", -1, "ptr", 0, "int", 0 )[0]
$tWstr = DllStructCreate( "wchar[" & $iLen & "]" )
DllCall( $hDLL, "int", "MultiByteToWideChar", "uint", 65001, "dword", 0, "ptr", $pStr, "int", -1, "struct*", $tWstr, "int", $iLen )
$aDisplay[$i-$iFrom][$j] = DllStructGetData( $tWstr, 1 )
Next
Next
Return
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
#forceref $hWnd, $iMsg, $wParam
EndFunc
Func _SQLite_GetTableEx( $hDB, $sSQL, ByRef $pTable, ByRef $iRows, ByRef $iCols )
If __SQLite_hChk($hDB, 2) Then Return SetError(@error, 0, $SQLITE_MISUSE)
Local $tSQL8 = __SQLite_StringToUtf8Struct($sSQL)
If @error Then Return SetError(3, @error, 0)
Local $avRval = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_get_table", _
"ptr", $hDB, _ ; An open database
"struct*", $tSQL8, _ ; SQL to be executed
"ptr*", 0, _ ; Results of the query
"int*", 0, _ ; Number of result rows
"int*", 0, _ ; Number of result columns
"long*", 0) ; Error msg written here
If @error Then Return SetError(1, @error, $SQLITE_MISUSE) ; DllCall error
$pTable = $avRval[3]
$iRows = $avRval[4]
$iCols = $avRval[5]
EndFunc
Func _SQLite_FreeTable( $pTable )
DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_free_table", "ptr", $pTable)
If @error Then Return SetError(1, @error, $SQLITE_MISUSE) ; DllCall error
EndFunc