maniootek Posted July 1, 2016 Share Posted July 1, 2016 (edited) This happens to me again. GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") cause _ArrayDisplay pop up freeze without any data displayed. Code example: expandcollapse popup#include <WindowsConstants.au3> ;$WM_NOTIFY #include <GUIConstantsEx.au3> ;$GUI_RUNDEFMSG #include <GuiListView.au3> ;$tagNMHDR #include <Array.au3> GUICreate("") $idListview = GUICtrlCreateListView("col1", 5, 5) GUICtrlCreateListViewItem("item", $idListview) GUICtrlCreateListViewItem("item", $idListview) Local $aArray[0] for $i=0 to 10 _ArrayAdd($aArray, $i) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = GUICtrlGetHandle($idListview) If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hWndListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case -3 ;$NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $index = DllStructGetData($tInfo, "Index") $subitemNR = DllStructGetData($tInfo, "SubItem") If $index <> -1 Then ;msgbox(0,0,$index & $subitemNR) _ArrayDisplay($aArray) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY result any idea what could be wrong? is it a bug? Edited July 1, 2016 by Melba23 Amended title Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 1, 2016 Moderators Share Posted July 1, 2016 maniootek, Most certainly not a bug and entirely due to your code. The Help file is quite clear: Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!! _ArrayDisplay is a blocking function - so the crash is quite expected. You need to set a flag in the handler and then action it in your idle loop - like this: expandcollapse popup#include <WindowsConstants.au3> ;$WM_NOTIFY #include <GUIConstantsEx.au3> ;$GUI_RUNDEFMSG #include <GuiListView.au3> ;$tagNMHDR #include <Array.au3> Global $fActivated = False GUICreate("") $idListview = GUICtrlCreateListView("col1", 5, 5) GUICtrlCreateListViewItem("item", $idListview) GUICtrlCreateListViewItem("item", $idListview) Local $aArray[0] for $i=0 to 10 _ArrayAdd($aArray, $i) Next GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idOK ExitLoop EndSwitch If $fActivated Then $fActivated = False ;msgbox(0,0,$index & $subitemNR) _ArrayDisplay($aArray) EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = GUICtrlGetHandle($idListview) If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($hWndListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case -3 ;$NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $index = DllStructGetData($tInfo, "Index") $subitemNR = DllStructGetData($tInfo, "SubItem") If $index <> -1 Then $fActivated = True EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY M23 Synapsee and maniootek 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
maniootek Posted July 1, 2016 Author Share Posted July 1, 2016 Thank you, it works now. 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