Sign in to follow this  
Followers 0
Aceguy

Clicked Icon (listview)

1 post in this topic

#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <GuiConstantsEx.au3>

Global Const $HDN_FIRST = -300
Global Const $HDN_ITEMCHANGINGA = $HDN_FIRST - 0
Global Const $HDN_BEGINTRACKA = $HDN_FIRST - 6
Opt("GUIOnEventMode", 1)
$Gui = GUICreate("Test", 500, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
$hListView = _GUICtrlListView_Create($GUI, "|Name|Location|ScD|Comments|", 10, 55, 480, 135,$LVS_REPORT, $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($hListView,$LVS_EX_SUBITEMIMAGES)

_GUICtrlListView_SetColumnWidth($hListView, 0, 25)
_GUICtrlListView_SetColumnWidth($hListView, 1, 75)
_GUICtrlListView_SetColumnWidth($hListView, 2, 200)
_GUICtrlListView_SetColumnWidth($hListView, 3, 50)
_GUICtrlListView_SetColumnWidth($hListView, 4, 75)
_GUICtrlListView_SetColumnWidth($hListView, 5, 25)

$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon ($hImage, "shell32.dll", 4)
_GUIImageList_AddIcon ($hImage, "shell32.dll",54)
_GUIImageList_AddIcon ($hImage, "shell32.dll",62)
_GUICtrlListView_SetImageList($hListView, $hImage, 1)


_GUICtrlListView_AddItem($hListView, '',0)

_GUICtrlListView_AddSubItem ($hListView, 0,'n',1,-1)

_GUICtrlListView_AddSubItem ($hListView, 0,'l',2, -1)
_GUICtrlListView_AddSubItem ($hListView, 0,'s',3, -1)
_GUICtrlListView_AddSubItem ($hListView, 0,'c',4, -1)
_GUICtrlListView_AddSubItem ($hListView,0,'',5,2)
GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
   sleep(100)
WEnd
;------------------------------------------------------------------------------

Func _ListView_Click($hWnd, $iIndex)
 
 ;  If _GUICtrlListView_GetItemStateImage($hWnd, $iIndex) = 1 Then
 ;    _GUICtrlListView_SetItemStateImage($hListView, $iIndex, 0)
 ;  Else
 ;    _GUICtrlListView_SetItemStateImage($hListView, $iIndex, 1)
 ;  EndIf
EndFunc  ;==>_ListView_Click

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
    $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_KEYDOWN; A key has been pressed
                Case $NM_CLICK; Sent by a list-view control when the user clicks an item with the left mouse button
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    Local $iIndex = DllStructGetData($tInfo, "Index")
                    
                    If $iIndex <> -1 Then
                        Local $iX = DllStructGetData($tInfo, "X")
                        Local $iPart = 1
                        If _GUICtrlListView_GetView($hListView) = 1 Then $iPart = 2;for large icons view
                        
                        Local $aIconRect = _GUICtrlListView_GetItemRect($hListView, $iIndex, $iPart)
                        
                        If $iX < $aIconRect[0] And $iX >= 5 Then
                            _ListView_Click($hWndListView, $iIndex)
                            Return 0
                        EndIf
                    EndIf
                   
                   ; No return value
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_NOTIFY

Func quit()
    Exit
    GUIDelete($GUI)
EndFunc  ;==>quit

want to check wether i have click the BIN, and nothing else can be clicked or selected....

please :);)

Share this post


Link to post
Share on other sites



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
Sign in to follow this  
Followers 0