Info Posted July 22, 2010 Posted July 22, 2010 #Include <GuiListView.au3> #Include <GuiImageList.au3> $g = GUICreate("") $hList = _GUICtrlListView_Create($g, "",2,2, 200, 200, BitOR($lvs_icon, $lvs_list)) $hImage = _GUIImageList_Create() _GUIImageList_AddIcon($hImage, "myicon.ico") _GUICtrlListView_SetImageList($hList, $hImage) _GUICtrlListView_AddItem($hList, "Item", 0) GUISetState() While 1 If GUIGetMsg() = -3 Then Exit WEnd what am I doing wrong?
KaFu Posted July 22, 2010 Posted July 22, 2010 The $iType parameter for _GUICtrlListView_SetImageList() does not seem to be as optional as I thought ... #include <GuiListView.au3> #include <GuiImageList.au3> $g = GUICreate("") $hList = _GUICtrlListView_Create($g, "", 2, 2, 200, 200, BitOR($lvs_icon, $lvs_list)) $hImage = _GUIImageList_Create(16, 16, 5, 3, 1) ConsoleWrite($hImage & @CRLF) $res = _GUIImageList_AddIcon($hImage, @ScriptDir & "\myicon.ico") ConsoleWrite($res & @CRLF) $res = _GUICtrlListView_SetImageList($hList, $hImage,1) ConsoleWrite($res & @CRLF) $res = _GUICtrlListView_AddItem($hList, "Item", 0) ConsoleWrite($res & @CRLF) GUISetState() While 1 If GUIGetMsg() = -3 Then Exit WEnd OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Info Posted July 22, 2010 Author Posted July 22, 2010 (edited) awesome, thanks One more question, how can I increase the size of the listview items? I used to use GUICtrlSetFont() on ListBox controls but it doesn't seem to work with ListViews Edited July 22, 2010 by Info
KaFu Posted July 22, 2010 Posted July 22, 2010 Thats easy ... expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GuiListView.au3> #include <GuiImageList.au3> #include <Winapi.au3> #include <FontConstants.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> $h_Report_ListView_Font = _WinAPI_CreateFont(30, 0, 0, 0, 600, False, False, False, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, _ $CLIP_DEFAULT_PRECIS, $PROOF_QUALITY, 0, "Tahoma") OnAutoItExitRegister("_OnAutoItExitRegister") Func _OnAutoItExitRegister() _WinAPI_DeleteObject($h_Report_ListView_Font) EndFunc $g = GUICreate("") $hList = _GUICtrlListView_Create($g, "", 2, 2, 200, 200, BitOR($lvs_icon, $lvs_list)) $hImage = _GUIImageList_Create(16, 16, 5, 3, 1) $res = _GUIImageList_AddIcon($hImage, @ScriptDir & "\myicon.ico") $res = _GUICtrlListView_SetImageList($hList, $hImage, 1) $res = _GUICtrlListView_AddItem($hList, "Item", 0) GUIRegisterMsg($WM_NOTIFY, "My_WM_NOTIFY") GUISetState() While 1 If GUIGetMsg() = -3 Then Exit WEnd Func My_WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hList Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam) Switch DllStructGetData($tCustDraw, "dwDrawStage") Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW ;request custom drawing of items EndSwitch Local $hDC = DllStructGetData($tCustDraw, 'hdc') _WinAPI_SelectObject($hDC, $h_Report_ListView_Font) Return $CDRF_NEWFONT EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>My_WM_NOTIFY OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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