找回密码
 加入
搜索
查看: 2037|回复: 2

[效率算法] 【已解决】如何快速的让Listview显示新的数据

[复制链接]
发表于 2012-2-5 13:37:47 | 显示全部楼层 |阅读模式
本帖最后由 zch11230 于 2012-2-5 19:59 编辑

有的论坛会限制或禁止搜索功能 所以做了一个自用的采集 搜索小工具  先用post采集需要版块的标题和贴子ID  搜索时 我用的StringInStr 循环对比每一条记录 如果贴子标题中含有我搜索的关键字  就显示在Listview上   现在有1W多条数据    但速度还可以 1秒左右就能完成 不知道有没有更快的方法   现在主要的问题是我在搜索完一个关键字之后 如果符合的条件有点多 我需要搜索新的关键字 但在删除旧数据时就比较慢了  用_GUICtrlListView_DeleteAllItems() 假如有1W条记录  删都要删近10秒  然后我又试了GUICtrlDelete 再GUICtrlCreateListView 这个速度快那么点 但在新数据显示出来之前 窗口会假死   但我看AFAN的 "AuiChm函数询捕" 新数据显示都是非常快的 而且不会影响窗口 求指教

搜索部分:

Func _search($search)
        GUICtrlDelete($ListView1)
        $ListView1 = GUICtrlCreateListView("ID|标题", 10, 60, 580, 280, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_REPORT))
        $hListView = GUICtrlGetHandle($ListView1)
        _GUICtrlListView_SetColumnWidth($ListView1, 0, 60)
        _GUICtrlListView_SetColumnWidth($ListView1, 1, 480)
;~         _GUICtrlListView_DeleteAllItems($ListView1)
        $file = FileOpen($txt)
        If $file = -1 Then Exit
        While 1
                $read = FileReadLine($file)
                If @error = -1 Then ExitLoop
                $str = StringSplit($read, "|")
                Select
                        Case $search = ""
                                GUICtrlCreateListViewItem($str[1] & "|" & $str[2], $ListView1)
                        Case StringInStr($str[2], $search)
                                GUICtrlCreateListViewItem($str[1] & "|" & $str[2], $ListView1)
                EndSelect
        WEnd
        FileClose($file)
EndFunc   ;==>_search
发表于 2012-2-5 15:10:40 | 显示全部楼层
_GUICtrlListView_BeginUpdate() 之后再 _GUICtrlListView_DeleteAllItems()
最后 _GUICtrlListView_EndUpdate()
 楼主| 发表于 2012-2-5 19:59:06 | 显示全部楼层
感谢AFAN  果然就好了  没有假死。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-3 02:05 , Processed in 0.073171 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表