yutijang Posted February 18, 2019 Posted February 18, 2019 Hello everyone! I have two function WM_NOTIFY, the one use for restrict change column width on list view. Another one use for Vkey, left click, right click on list view items. I found them in this great forum. So, how i mix them to one function only? Func _WM_NOTIFY_($hWnd, $iMsg, $wParam, $lParam) ; Get details of message Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) ; Look for header resize code $iCode = DllStructGetData($tNMHEADER, "Code") Switch $iCode Case $HDN_BEGINTRACKW ; Now get column being resized Local $iCol = DllStructGetData($tNMHEADER, "Item") If $iCol = 0 Or $iCol = 1 Then ; Prevent resizing Return True Else ; Allow resizing Return False EndIf EndSwitch EndFunc Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $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 Switch $iCode Case $LVN_KEYDOWN $tStruct = DllStructCreate($tagNMLVKEYDOWN, $lParam) $iKey = DllStructGetData($tStruct, "VKey") Switch $iKey Case 38 ;Up key Case 40 ;Down key Case 46 ;Delete key _GUICtrlListView_DeleteItemsSelected($hListView) EndSwitch Case $NM_CLICK ;Left click ;MsgBox(0,"","") Case $NM_RCLICK ; Right click. Sent by a list-view control when the user clicks an item with the left mouse button ListView_RClick() Return 0 EndSwitch EndSwitch $tNMHDR = 0 $hWndFrom = 0 $iIDFrom = 0 $iCode = 0 Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I tried mix them and failed, i do not know any solution for this. Hope for yours help! Thank so much! Sorry for my English.
yutijang Posted February 18, 2019 Author Posted February 18, 2019 Hello, I found solution, i do not know if it's right or not but it working for me. It's here expandcollapse popupFunc _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $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 Switch $iCode Case $LVN_KEYDOWN $tStruct = DllStructCreate($tagNMLVKEYDOWN, $lParam) $iKey = DllStructGetData($tStruct, "VKey") Switch $iKey Case 38 ;Up key Case 40 ;Down key Case 46 ;Delete key _GUICtrlListView_DeleteItemsSelected($hListView) EndSwitch Case $NM_CLICK ;Left click ;MsgBox(0,"","") Case $NM_RCLICK ; Right click. Sent by a list-view control when the user clicks an item with the left mouse button ListView_RClick() Return 0 EndSwitch Case Else Local $tNMHEADER = DllStructCreate($tagNMHEADER, $lParam) ; Look for header resize code $iCode = DllStructGetData($tNMHEADER, "Code") Switch $iCode Case $HDN_BEGINTRACKW ; Now get column being resized Local $iCol = DllStructGetData($tNMHEADER, "Item") If $iCol = 0 Or $iCol = 1 Then ; Prevent resizing Return True Else ; Allow resizing Return False EndIf EndSwitch EndSwitch $tNMHDR = 0 $hWndFrom = 0 $iIDFrom = 0 $iCode = 0 Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Thanks for reading! Sorry for my bad English.
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