Jump to content

Problem with _GUICtrlListView_DeleteAllItems


Recommended Posts

Hi,

sorry for my english...

I write program:

#include <GUIConstants.au3>
#Include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>

Global $iLastItem = -1, $iLastsubitemNR = -1
Global $hGUI_Multiline, $View_Multiline, $ColName
Global $nCurCol = -1
Global $nSortDir = 1
Global $bSet = 0
Global $nCol = -1

$iLastI = 0
$iLastsubi = 0

$GUI = GUICreate("List", 300,250, -1, -1,$WS_MAXIMIZEBOX + $WS_MINIMIZEBOX)


$hListView = GuiCtrlCreateListView("", 0,0, 297, 150,-1, BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT ))
GUICtrlSetResizing($hListView, $GUI_DOCKTOP)

$dayst = GUICtrlCreateCombo ("", 10,170,280,20, BitOr($CBS_DROPDOWNLIST, $WS_VSCROLL, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1,"1|2|3")

_GUICtrlListView_AddColumn($hListView, "col1")
_GUICtrlListView_AddColumn($hListView, "col2")
_GUICtrlListView_AddColumn($hListView, "col3")

Dim $array[10000][9]

For $i = 0 to 9999
    For $j = 0 To 8
        $array[$i][$j] = $i
    Next
Next

_GUICtrlListView_AddArray($hListView,$array)

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $dayst
            $timer = TimerInit()
            _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
            ConsoleWrite(@LF&"delete time = "&TimerDiff($timer))
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete($GUI)
            Exit
    EndSelect
WEnd


Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)

    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")


Switch $hWndFrom
    Case $hWndListView
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                    Local $iItem = DllStructGetData($tInfo, "Item") ; строка
                    Local $subitemNR = DllStructGetData($tInfo, "SubItem")
            Switch $iCode
                Case $NM_DBLCLK
                    $timer = TimerInit()
                    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
                    ConsoleWrite(@LF&"delete time = "&TimerDiff($timer))
            EndSwitch
EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc

If I use double click on any cell then operating time of _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView)) = 150 ms

If I use select any position of $dayst then operating time of _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView)) = 3000 ms

How to receive equally small times?

Link to comment
Share on other sites

The problem is solved. The problem was with GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

I have changed a code as follows

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $dayst
            GUIRegisterMsg($WM_NOTIFY, "")
            $timer = TimerInit()
            _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
            ConsoleWrite(@LF&"delete time = "&TimerDiff($timer))
            GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete($GUI)
            Exit
    EndSelect
WEnd
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...