begin10 Posted February 18, 2008 Share Posted February 18, 2008 I have a listview control that I need to display 12,000 items. The current listview only displays 4000 items. I checked into the listview object but I'm not that advanced. any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 18, 2008 Moderators Share Posted February 18, 2008 randallc did a lot of work on listview stuff, you may find it useful: http://www.autoitscript.com/forum/index.ph...mp;#entry189575 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
randallc Posted February 18, 2008 Share Posted February 18, 2008 Hi,Thanks,I think best is in new topic;Virtual ListView;Fast New ArrayDisplayBest, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
begin10 Posted February 19, 2008 Author Share Posted February 19, 2008 Am i doing something wrong when I run the script my listview now is flickering very weird behavior. Is my autoit settings wrong here is an example script. AutoIt Version: 3.2.11.0 (beta) #include <_GUICtrlListView.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Script Start - Add your code below here #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 447, 193, 125) $ListView1 = _GUICtrlCreateListView("ID", 264, 72, 321, 321, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_TRACKSELECT)) GUICtrlSendMsg(-1, 0x101E, 0, 50) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _startup() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _startup() For $i = 1 To 12000 Step 1 _GUICtrlCreateListViewItem("item#" & $i, $ListView1) Next EndFunc Link to comment Share on other sites More sharing options...
randallc Posted February 19, 2008 Share Posted February 19, 2008 hi, I have not fixed that since some old versions.. Try this; [thanks @siao] expandcollapse popup; lvex.au3 #include <_GUICtrlListView.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ; Script Start - Add your code below here #include <GUIConstants.au3> Global $tTextBufferV, $sSeparatorV,$aArrayV[1] Global const $LVS_OWNERDATA=0x1000 $sTextBuff = "char[261]" If Execute("@Unicode") Then $sTextBuff = "w" & $sTextBuff $tTextBufferV = DllStructCreate($sTextBuff) Global $iNum = 120000 $aArrayV = _startup($iNum) MsgBox(64,"Ready?","Count the time for "&$iNum&" items!") #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 633, 447, 193, 125) $ListView1 = GUICtrlCreateListView("ID", 264, 72, 321, 321, $LVS_SHOWSELALWAYS + $LVS_OWNERDATA, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) ;~ $ListView1 = GUICtrlCreateListView("ID", 264, 72, 321, 321, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) GUICtrlSendMsg(-1, 0x101E, 0, 100) GUICtrlSendMsg($ListView1, $LVM_SETITEMCOUNT, $iNum, 0) ;;set total item count - necessary for virtual lv Local $wProcNew = DllCallbackRegister("_ArrayUDF_WM_NOTIFY", "ptr", "hwnd;uint;long;ptr") ;;register new window proc Local $wProcOld = _ArrayUDF_WinSubclass($Form1, DllCallbackGetPtr($wProcNew)) ;;sublass gui Assign('ArrayUDF_wProcOld', $wProcOld, 2) ;; $ArrayUDF_wProcOld = global keeper of old windowproc ptr ; Set interface up GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _startup($iNumF) Local $aStart[$iNumF] For $i = 0 To $iNumF - 1 Step 1 $aStart[$i] = "item#" & $i ;~ GUICtrlCreateListViewItem("item#" & $i, $ListView1) Next Return $aStart EndFunc ;==>_startup Func _ArrayUDF_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $wProcOld = Eval('ArrayUDF_wProcOld'), $i, $j, $tNMLVDISPINFO, $text, $textlen, $maxlen ;;$WM_NOTIFY = 0x004E If $Msg <> 0x004E Then Return _ArrayUDF_CallWndProc($wProcOld, $hWnd, $Msg, $wParam, $lParam) Local $tNMHDR = DllStructCreate("hwnd hwndfrom;int idfrom;int code", $lParam) Local $hWndFrom = DllStructGetData($tNMHDR, "hwndfrom"), $iCode = DllStructGetData($tNMHDR, "code") ;; the following is not very good, better would be have listview handle available in global scope. If ControlGetHandle($hWnd, "", "[Class:SysListView32;Instance:1]") = $hWndFrom Then Switch $iCode Case - 150, -177 ;;$LVN_GETDISPINFOA = -150, $LVN_GETDISPINFOW = -177 ;;give requested items one by one (kinda slow if a lot of items are visible at the same time) $tNMLVDISPINFO = DllStructCreate("hwnd hwndfrom;int idfrom;int code;" & _ "uint mask;int item;int subitem;uint state;uint statemask;ptr text;int textmax;int;dword lparam;int;uint[5]", $lParam) If BitAND(DllStructGetData($tNMLVDISPINFO, "mask"), $LVIF_TEXT) Then $i = Dec(Hex(DllStructGetData($tNMLVDISPINFO, "item"))) $text = $aArrayV[$i] $textlen = StringLen($text) $maxlen = DllStructGetSize($tTextBufferV) If Execute("@Unicode") Then $maxlen = $maxlen / 2 If $textlen > $maxlen - 1 Then $text = StringLeft($text, $maxlen - 1) DllStructSetData($tTextBufferV, 1, $text) DllStructSetData($tNMLVDISPINFO, "textmax", $textlen) DllStructSetData($tNMLVDISPINFO, "text", DllStructGetPtr($tTextBufferV)) EndIf EndSwitch EndIf ;;pass the unhandled messages to default WindowProc Return _ArrayUDF_CallWndProc($wProcOld, $hWnd, $Msg, $wParam, $lParam) EndFunc ;==>_ArrayUDF_WM_NOTIFY Func _ArrayUDF_WinSubclass($hWnd, $lpNewWindowProc) ;#define GWL_WNDPROC (-4) Local $aTmp, $sFunc = "SetWindowLong" If Execute("@Unicode") Then $sFunc &= "W" $aTmp = DllCall("user32.dll", "ptr", $sFunc, "hwnd", $hWnd, "int", -4, "ptr", $lpNewWindowProc) If @error Then Return SetError(1, 0, 0) If $aTmp[0] = 0 Then Return SetError(1, 0, 0) Return $aTmp[0] EndFunc ;==>_ArrayUDF_WinSubclass Func _ArrayUDF_CallWndProc($lpPrevWndFunc, $hWnd, $Msg, $wParam, $lParam) Local $aRet = DllCall('user32.dll', 'uint', 'CallWindowProc', 'ptr', $lpPrevWndFunc, 'hwnd', $hWnd, 'uint', $Msg, 'wparam', $wParam, 'lparam', $lParam) ;~ If @error Then Return 0 Return $aRet[0] EndFunc ;==>_ArrayUDF_CallWndProcRandall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
begin10 Posted February 19, 2008 Author Share Posted February 19, 2008 Thanks randallc it is fast and reliable. It is Awesome, Thank you to SmOke_N. Link to comment Share on other sites More sharing options...
begin10 Posted February 19, 2008 Author Share Posted February 19, 2008 What if i have more than one column. Say $ListView1 = GUICtrlCreateListView("Name|ID", 264, 72, 321, 321, $LVS_SHOWSELALWAYS + $LVS_OWNERDATA, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) When I run this it just copies data from column1 to column2. Link to comment Share on other sites More sharing options...
randallc Posted February 19, 2008 Share Posted February 19, 2008 (edited) What if i have more than one column. Say $ListView1 = GUICtrlCreateListView("Name|ID", 264, 72, 321, 321, $LVS_SHOWSELALWAYS + $LVS_OWNERDATA, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_TRACKSELECT)) When I run this it just copies data from column1 to column2.Hi, depends if your array is array of delimited strings, or 2D? modify "NOTIFY"; eg (see the link I gave to "_ArrayDisplay" look at various )"NOTIFY" options; Best, Randall eg If BitAND(DllStructGetData($tNMLVDISPINFOV, "mask"), $LVIF_TEXT) Then $i = Dec(Hex(DllStructGetData($tNMLVDISPINFOV, "item"))) $j = DllStructGetData($tNMLVDISPINFOV, "subitem") ;================================================================ If $j = 0 Then $text = "[" & $i & "]" Else $text = $avArrayV[$i][$j - 1] EndIf ;================================================================ $textlen = StringLen($text) If $textlen > $maxlenV - 1 Then $text = StringLeft($text, $maxlenV - 1) DllStructSetData($tTextBufferV, 1, $text) DllStructSetData($tNMLVDISPINFOV, "textmax", $textlen) DllStructSetData($tNMLVDISPINFOV, "text", $tTextPtrV)oÝ÷ Ù»jË.ë2¢èZ½æ§w^ÅÊ%ºiâuêÚ³¥§u©e="²Ø¥*.®Æ¦{PÚ®¶²¡÷(º»jëh×6 ;================================================================ If $j = 0 Then $text = "[" & $i & "]" Else $text = $aArray[$i] EndIf Edited February 19, 2008 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
randallc Posted February 20, 2008 Share Posted February 20, 2008 PS For full features, more routine syntax, UDFs now will do over 4000; just not quite so fast; "_GUICtrlListView_AddSubItem " etc; see helpfile with example scripts Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
begin10 Posted February 20, 2008 Author Share Posted February 20, 2008 Thanks randallc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now