marcsusy Posted October 20, 2013 Posted October 20, 2013 Hello everyone I would like to know how to create a ListView object to disable items individually thanks
FireFox Posted October 20, 2013 Posted October 20, 2013 Hi,I would like to know how to create a ListView object to disable items individuallySure, what do you mean by disable? Stop the item to be highlighted?Br, FireFox.
marcsusy Posted October 20, 2013 Author Posted October 20, 2013 Hello Firefox That the ítem is idle you can not select or delete or edit. Thanks
FireFox Posted October 20, 2013 Posted October 20, 2013 (edited) That the ítem is idle you can not select or delete or edit.I don't understand why you want to disable delete/edit as it's not internal listview functions (not available when creating listview/items).Do you want to perform this on your own autoit script? Edited October 20, 2013 by FireFox
marcsusy Posted October 20, 2013 Author Posted October 20, 2013 (edited) Hello Firefox This is an exmple:expandcollapse popup#include <GuiListView.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 623, 449, 192, 114) $ListView1 = GUICtrlCreateListView("Nº| Column", 176, 136, 330, 150, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 457) _GUICtrlListView_GetColumn($listview1, 0) _GUICtrlListView_JustifyColumn($listview1, 0, 2) _GUICtrlListView_GetColumn($listview1, 1) _GUICtrlListView_JustifyColumn($listview1, 1, 0) $Button1 = GUICtrlCreateButton("Button1", 232, 336, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 408, 336, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $Item[1],$f = 0 $List = ObjGet($ListView1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 to 10 $Item[$f] = GUICtrlCreateListViewItem($i &"| MiembroTipo& ", $listview1) $f += 1 Redim $Item[$f + 1] Next Case $Button2 For $i = 0 to 10 ; For example ; I want to disable the items from 1 to 5 Next EndSwitch WEnd Edited October 20, 2013 by Melba23 Added code tags
Moderators Melba23 Posted October 20, 2013 Moderators Posted October 20, 2013 marsusy,You can remove the checkboxes like this - credit goes to dragan: expandcollapse popup#include <GuiListView.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> $Form1 = GUICreate("Form1", 623, 449, 192, 114) $ListView1 = GUICtrlCreateListView("Nº| Column", 176, 136, 330, 150, -1, BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 457) _GUICtrlListView_GetColumn($ListView1, 0) _GUICtrlListView_JustifyColumn($ListView1, 0, 2) _GUICtrlListView_GetColumn($ListView1, 1) _GUICtrlListView_JustifyColumn($ListView1, 1, 0) $Button1 = GUICtrlCreateButton("Button1", 232, 336, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 408, 336, 75, 25) GUISetState(@SW_SHOW) Local $Item[1], $f = 0 GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;required for preventing checkboxes from re-apearing While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 For $i = 0 To 10 $Item[$f] = GUICtrlCreateListViewItem($i & "| MiembroTipo& ", $ListView1) $f += 1 ReDim $Item[$f + 1] Next Case $Button2 For $i = 0 To 4 _RemoveCheckbox(GUICtrlGetHandle($ListView1), $i) Next EndSwitch WEnd Func _RemoveCheckbox($LVM, $nIndex) _GUICtrlListView_SetItemState($LVM, $nIndex, 0, $LVIS_STATEIMAGEMASK) _WinAPI_RedrawWindow($LVM) EndFunc Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam) #forceref $hWndGUI, $MsgID, $wParam Local $tNMHDR, $hwndFrom, $code, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $LParam) $hwndFrom = DllStructGetData($tNMHDR, "hWndFrom") $code = DllStructGetData($tNMHDR, "Code") Local $hWndListView = $ListView1 If Not IsHWnd($ListView1) Then $hWndListView = GUICtrlGetHandle($ListView1) Switch $hwndFrom Case $hWndListView Switch $code Case $NM_CLICK, $NM_DBLCLK, $NM_RCLICK, $NM_RDBLCLK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $LParam) ;preventing checkboxes from re-apearing (same conditions as above) Switch DllStructGetData($tInfo, "Index") Case 0 To 4 Return True;intercept normal return message which would cause checkbox to re-apear EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFuncIs that what you wanted? M23P.S. And you have been here long enough to know that when you post code you should use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. 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
marcsusy Posted October 20, 2013 Author Posted October 20, 2013 Many Thanks for the help Firefox,Melba,Dragan something like what I wanted, I works well
perka75 Posted September 8, 2014 Posted September 8, 2014 Sorry to be resurrecting an old post, but I have a quick question on this topic and please pardon my "noobiness"! I am very new to the world of AutoIT and DLL Structures are very confusing to say the least! Is there a way to achieve the same result as in Melba23's post, but with the checkboxes (0-4) being checked instead of unchecked (and disabled from changing of course)? Which part of the WM_NOTIFY function would I need to change? Many thanks for any help
MikahS Posted September 8, 2014 Posted September 8, 2014 (edited) Use: Local $chkbox[5] ; set each checkbox to their index value $chkbox[0] = first checkbox, $chkbox[1] = second checkbox, etc For $i = 0 To UBound($chkbox) - 1 Step 1 GUICtrlSetState($chkbox[$i], $GUI_CHECKED) ; replace the variable holding the checkbox 1-4 in the first param. Next Edited September 8, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
perka75 Posted September 8, 2014 Posted September 8, 2014 Doh! But of course.... Just realized that the WM_NOTIFY function, just prevents the change... I can create the items checked in the first place! How I can do this with my script is another story :-), but thanks a lot MikahS for pointing me in the right direction. Really appreciate the quick response!
MikahS Posted September 9, 2014 Posted September 9, 2014 no problem Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
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