Sign in to follow this  
Followers 0
Aceguy

Listview Help

3 posts in this topic




Hi!

Example:

#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

$Gui = GUICreate("Test", 320, 220)

$hListView = _GUICtrlListView_Create($GUI, "Items|SubItems1|SubItems2", 10, 10, 300, 200, BitOR($LVS_EDITLABELS, $LVS_REPORT), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_SUBITEMIMAGES, $LVS_EX_FULLROWSELECT))

_GUICtrlListView_SetColumnWidth($hListView, 0, 98)
_GUICtrlListView_SetColumnWidth($hListView, 1, 98)
_GUICtrlListView_SetColumnWidth($hListView, 2, 80)

$hImage = _GUIImageList_Create(16, 16, 5, 3)
_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, 2)
_GUICtrlListView_AddSubItem ($hListView, 1,'22', 1, 1)
_GUICtrlListView_AddSubItem ($hListView, 2,'11', 1, 0)
_GUICtrlListView_AddSubItem ($hListView, 3,'33', 1, 3)

_GUICtrlListView_AddSubItem ($hListView, 0,'New', 2, 1)
_GUICtrlListView_AddSubItem ($hListView, 1,'Page', 2, 3)
_GUICtrlListView_AddSubItem ($hListView, 2,'Sys', 2, 2)
_GUICtrlListView_AddSubItem ($hListView, 3,'Device', 2, 0)

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 $tNMHDR, $iCode, $tInfo, $iItem
    
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $iCode
    Case $HDN_ITEMCHANGINGA, $HDN_BEGINTRACKA
        $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
        $iItem = DllStructGetData($tInfo, "Item")
        If $iItem = _GUICtrlListView_GetColumnCount($hListView) - 1 Then Return 1
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
:)

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