Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Listview column resize + WM_NOTIFY + Run(@Comspec = result crash

$
0
0
I am getting my script crashed if I use functions like WM_NOTIFY for listview + cmd function + reading it when resizing the listview column. While this example script is running, try to resize listview's column, hold on the column size-bar for some time, resize both, forward and backward, you'll see that the script will crash. Why is that?
[ autoit ]         
#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Constants.au3> $Form1 = GUICreate("Form1", 500, 400) $List1 = GUICtrlCreateListView("col 1|col 2|col 3|col 4|col 5", 0, 0, 500, 400) For $i = 0 to 4 _GUICtrlListView_SetColumnWidth($List1, $i, 95) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") AdlibRegister("updatelist", 2000) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func updatelist() if _GUICtrlListView_GetItemCount($List1) >= 10 Then For $i = 0 to Random(2, 4, 1) _GUICtrlListView_DeleteItem($List1, $i) Next Else For $i = 1 to Random(1, 3, 1) GUICtrlCreateListViewItem("data1data1data1|data2data2data2|data3data3data3|data4data4data4|data5data5data5", $List1) Next EndIf Local $iPID = Run(@ComSpec & ' /c netstat -nao', @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD) if @error then Return SetError(3, 0, 0) Local $sOutput While 1      $sOutput &= StdoutRead($iPID)      If @error Then          ExitLoop      EndIf Sleep(100) WEnd ConsoleWrite($sOutput & @LF) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $List1 If Not IsHWnd($List1) Then $hWndListView = GUICtrlGetHandle($List1) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom      Case $hWndListView          Switch $iCode              Case $NM_CUSTOMDRAW ; randomly chosen function, the more functions there are = the more chance you get crash                  Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam)                  Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")                  Switch $iDrawStage                      Case $CDDS_PREPAINT                          Return $CDRF_NOTIFYITEMDRAW                      Case $CDDS_ITEMPREPAINT                          Return $CDRF_NOTIFYSUBITEMDRAW                  EndSwitch                  Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")                  If $iSubItem = 4 Then DllStructSetData($tCustDraw, "clrText", 0x038507)                  Return $CDRF_NEWFONT          EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>