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

Listview Group WM_NOTIFY trigger ?

$
0
0

Does anyone know, how to be notified when a Listview Group has been clicked, or expanded, etc. ?

AutoIt         
  1. #include <GUIConstantsEx.au3>
  2. #include <GuiImageList.au3>
  3. #include <GuiListView.au3>
  4. #include <WindowsConstants.au3>
  5. #include <MsgBoxConstants.au3>
  6.  
  7. Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
  8.     Local $tInfo, $tNMHDR = DllStructCreate($tagNMHDR, $lParam), $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  9.     Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom"), $iCode = DllStructGetData($tNMHDR, "Code")
  10.     Switch $hWndFrom
  11.         Case $hWndListView
  12.             Switch $iCode
  13.  
  14.             ;   Case $of?????? ; A Group was clicked       <---- I need help with this
  15.  
  16.  
  17.                 Case $LVN_COLUMNCLICK ; A column was clicked
  18.                     $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
  19.                     _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
  20.                             "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
  21.                             "-->Code:" & @TAB & $iCode & @CRLF & _
  22.                             "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
  23.                             "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
  24.                             "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
  25.                             "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
  26.                             "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
  27.                             "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
  28.                             "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
  29.                             "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
  30.                     ; No return value
  31.                 Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
  32.                     $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
  33.                     _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
  34.                             "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
  35.                             "-->Code:" & @TAB & $iCode & @CRLF & _
  36.                             "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
  37.                             "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
  38.                             "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
  39.                             "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
  40.                             "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
  41.                             "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
  42.                             "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
  43.                             "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
  44.                             "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
  45.                     ; No return value
  46.  
  47.             EndSwitch
  48.     EndSwitch
  49.     Return $GUI_RUNDEFMSG
  50. EndFunc   ;==>WM_NOTIFY
  51.  
  52. Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
  53.     ConsoleWrite( _
  54.             "!===========================================================" & @CRLF & _
  55.             "+======================================================" & @CRLF & _
  56.             "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
  57.             "+======================================================" & @CRLF)
  58. EndFunc   ;==>_DebugPrint
  59.  
  60. If Not StringInStr($CmdLineRaw, "/ErrorStdOut") Then Exit MsgBox($MB_TOPMOST, @ScriptName, 'please run from the editor, thanks', 10)
  61.  
  62. Global $idListview, $hWndListView
  63. Example()
  64.  
  65. Func Example()
  66.     Local $aInfo, $hImage, $idListview
  67.  
  68.     GUICreate("ListView Group COLLAPSIBLE", 400, 300)
  69.  
  70.     $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
  71.     $hWndListView = GUICtrlGetHandle($idListview)
  72.  
  73.     ; Load images
  74.     $hImage = _GUIImageList_Create()
  75.     _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0xFF0000, 16, 16))
  76.     _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x00FF00, 16, 16))
  77.     _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($idListview, 0x0000FF, 16, 16))
  78.     _GUICtrlListView_SetImageList($idListview, $hImage, 1)
  79.  
  80.     ; Add columns
  81.     _GUICtrlListView_AddColumn($idListview, "Column 1", 100)
  82.     _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
  83.     _GUICtrlListView_AddColumn($idListview, "Column 3", 100)
  84.  
  85.     ; Add items
  86.     _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
  87.     _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
  88.     _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
  89.     _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
  90.     _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
  91.     _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)
  92.  
  93.     ; Build groups
  94.     _GUICtrlListView_InsertGroup($idListview, -1, 1, "Group 1", 1)
  95.     _GUICtrlListView_SetGroupInfo($idListview, 1, "Group 1", 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED) ; <---
  96.     _GUICtrlListView_InsertGroup($idListview, -1, 2, "Group 2")
  97.     _GUICtrlListView_SetGroupInfo($idListview, 2, "Group 2", 0, $LVGS_COLLAPSIBLE + $LVGS_COLLAPSED) ; <---
  98.     _GUICtrlListView_SetItemGroupID($idListview, 0, 1)
  99.     _GUICtrlListView_SetItemGroupID($idListview, 1, 2)
  100.     _GUICtrlListView_SetItemGroupID($idListview, 2, 2)
  101.  
  102.     GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
  103.  
  104.     ; Loop until the user exits.
  105.     Do
  106.     Until GUIGetMsg() = $GUI_EVENT_CLOSE
  107.  
  108.     GUIDelete()
  109. EndFunc   ;==>Example
  1.  

Viewing all articles
Browse latest Browse all 12506

Trending Articles



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