Jump to content

Recommended Posts

Posted

Hi,

I would like to know how to create a ListView object to disable items individually

Sure, what do you mean by disable? Stop the item to be highlighted?

Br, FireFox.

Posted (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 by FireFox
Posted (edited)

Hello Firefox

 

This is an exmple:

#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 by Melba23
Added code tags
  • Moderators
Posted

marsusy,

You can remove the checkboxes like this - credit goes to dragan: :)

#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
EndFunc
Is that what you wanted? :huh:

M23

P.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. ;)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • 10 months later...
Posted

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

Posted (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 by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

Posted

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!

Posted

no problem ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My 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

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...