rasim Posted January 23, 2008 Share Posted January 23, 2008 Hi! How can get column index when click on column? expandcollapse popup#include <GuiListView.au3> #include <GuiImageList.au3> #include <GuiConstantsEx.au3> $hGui = GUICreate("Test", 400, 250) $hListView = _GUICtrlListView_Create($hGUI, "Items|SubItems1|SubItems2", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $hImage = _GUIImageList_Create (16,16,5); _GUIImageList_AddIcon ($hImage, "shell32.dll", 3); _GUIImageList_AddIcon ($hImage, "shell32.dll", 11); _GUIImageList_AddIcon ($hImage, "shell32.dll", 22); _GUIImageList_AddIcon ($hImage, "shell32.dll", 33); _GUICtrlListView_SetImageList ($hListView, $hImage, 1) _GUICtrlListView_AddItem($hListView, "Item1",0) _GUICtrlListView_AddItem($hListView, "Item2",2) _GUICtrlListView_AddItem($hListView, "Item3",1) _GUICtrlListView_AddItem($hListView, "Item4",3) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ;Here code for get clicked column index EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Link to comment Share on other sites More sharing options...
GaryFrost Posted January 23, 2008 Share Posted January 23, 2008 Look in the help in _GUICtrlListView_Create example BTW until you become an advanced user I would suggest using the Built-in GuiCtrlCreateListView, the UDFs will still work with the control. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
smashly Posted January 23, 2008 Share Posted January 23, 2008 Hi, Case $LVN_COLUMNCLICK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) ConsoleWrite("-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF) Cheers Link to comment Share on other sites More sharing options...
rasim Posted January 23, 2008 Author Share Posted January 23, 2008 (edited) Look in the help in _GUICtrlListView_Create example BTW until you become an advanced user I would suggest using the Built-in GuiCtrlCreateListView, the UDFs will still work with the control.Damn! I just unattentive! Thank you guys! expandcollapse popup#include <GuiListView.au3> #include <GuiImageList.au3> #include <GuiConstantsEx.au3> $Gui = GUICreate("Test", 400, 250) $hListView = _GUICtrlListView_Create($GUI, "Items|SubItems1|SubItems2", 2, 2, 220, 196, BitOR($LVS_EDITLABELS, $LVS_REPORT)) $hImage = _GUIImageList_Create (16,16,5); _GUIImageList_AddIcon ($hImage, "shell32.dll", 3); _GUIImageList_AddIcon ($hImage, "shell32.dll", 11); _GUIImageList_AddIcon ($hImage, "shell32.dll", 22); _GUIImageList_AddIcon ($hImage, "shell32.dll", 33); _GUICtrlListView_SetImageList ($hListView, $hImage, 1) _GUICtrlListView_AddItem($hListView, "Item1",0) _GUICtrlListView_AddItem($hListView, "Item2",2) _GUICtrlListView_AddItem($hListView, "Item3",1) _GUICtrlListView_AddItem($hListView, "Item4",3) _GUICtrlListView_AddSubItem ($hListView, 0,'44', 1) _GUICtrlListView_AddSubItem ($hListView, 1,'22', 1) _GUICtrlListView_AddSubItem ($hListView, 2,'11', 1) _GUICtrlListView_AddSubItem ($hListView, 3,'33', 1) _GUICtrlListView_AddSubItem ($hListView, 0,'New', 2) _GUICtrlListView_AddSubItem ($hListView, 1,'Page', 2) _GUICtrlListView_AddSubItem ($hListView, 2,'Sys', 2) _GUICtrlListView_AddSubItem ($hListView, 3,'Device', 2) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ;------------------------------------------------------------------------------ Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) Local $ColumnIndex = DllStructGetData($tInfo, "SubItem") MsgBox(0, "Column", "Pressed a " & $ColumnIndex & " column") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Edited January 23, 2008 by rasim 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