NunoBorges Posted September 20, 2011 Posted September 20, 2011 Viva, Is there a way to have on a listview: - ListView Line variable height. - Showing navigation through subitems in a ListView. Best regards #include <GUIConstantsEx.au3> ;#include <GUIListViewEx_20110824.au3>; by Melba23 #include <GUIListView.au3> #include <WindowsConstants.au3> Global $Font="MS Sans Serif" #Region ### START Koda GUI section ### Form=C:\AutoIt NDB Kit\Disk_Information\- NDBDiskInfo\ListView_Linha variável.kxf $Form1 = GUICreate("Form1", 443, 177, 192, 124) $ListView1 = GUICtrlCreateListView("Col1|Col2", 16, 16, 409, 145, BitOR($LVS_ICON,$LVS_NOSORTHEADER,$LVS_SINGLESEL), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES)) ;$LBS_OWNERDRAWVARIABLE=0x00000020 ;_GUICtrlListView_SetView($ListView1, 4) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200) GUICtrlSetFont(-1, 10, 400, 2, $Font) $ListView1_0 = GUICtrlCreateListViewItem("Col1_Lin1|Col2_Lin1 Col2_Lin2 Col2_Lin3 Col2_Lin4", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("Col1_Lin2|Col2_Lin2", $ListView1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $ListView1 EndSwitch WEnd
NunoBorges Posted September 20, 2011 Author Posted September 20, 2011 ListView Variable.au3 Sorry, Here are my example.
Moderators Melba23 Posted September 20, 2011 Moderators Posted September 20, 2011 NunoBorges, Alas, I have never found a way to highlight only the cell of a ListView. The best I can do is to highlight both the row and column - this shows you how to do it: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> Global $Font = "MS Sans Serif" Global $iColumn = -1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Form1 = GUICreate("Form1", 443, 177, 192, 124) $ListView1 = GUICtrlCreateListView("Col1|Col2", 16, 16, 409, 145, BitOR($LVS_ICON, $LVS_NOSORTHEADER, $LVS_SINGLESEL), $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1, 0xCCCCCC) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200) GUICtrlSetFont(-1, 10, 400, 2, $Font) $ListView1_0 = GUICtrlCreateListViewItem("Col1_Lin1|Col2_Lin1 Col2_Lin2 Col2_Lin3 Col2_Lin4", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("Col1_Lin2|Col2_Lin2", $ListView1) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $ListView1 EndSwitch If $iColumn <> -1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _GUICtrlListView_SetSelectedColumn($ListView1, $iColumn) $iColumn = -1 EndIf WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return Switch DllStructGetData($tStruct, 3) Case $NM_CLICK $iColumn = DllStructGetData($tStruct, 5) EndSwitch EndFunc ;==>_WM_NOTIFY Any help? M23 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: Reveal hidden contents 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
NunoBorges Posted September 20, 2011 Author Posted September 20, 2011 On 9/20/2011 at 5:04 PM, Melba23 said: NunoBorges, Alas, I have never found a way to highlight only the cell of a ListView. The best I can do is to highlight both the row and column - this shows you how to do it: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListView.au3> Global $Font = "MS Sans Serif" Global $iColumn = -1 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $Form1 = GUICreate("Form1", 443, 177, 192, 124) $ListView1 = GUICtrlCreateListView("Col1|Col2", 16, 16, 409, 145, BitOR($LVS_ICON, $LVS_NOSORTHEADER, $LVS_SINGLESEL), $WS_EX_CLIENTEDGE) GUICtrlSetBkColor(-1, 0xCCCCCC) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200) GUICtrlSetFont(-1, 10, 400, 2, $Font) $ListView1_0 = GUICtrlCreateListViewItem("Col1_Lin1|Col2_Lin1 Col2_Lin2 Col2_Lin3 Col2_Lin4", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("Col1_Lin2|Col2_Lin2", $ListView1) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $ListView1 EndSwitch If $iColumn <> -1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _GUICtrlListView_SetSelectedColumn($ListView1, $iColumn) $iColumn = -1 EndIf WEnd Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If @error Then Return Switch DllStructGetData($tStruct, 3) Case $NM_CLICK $iColumn = DllStructGetData($tStruct, 5) EndSwitch EndFunc ;==>_WM_NOTIFY Any help? M23 Thanks Thanks, I'll have to think of an alternative. But I will also continue looking at the msdn. friendly hug Nuno
Moderators Melba23 Posted September 20, 2011 Moderators Posted September 20, 2011 NunoBorges, If you find the answer, please let me know! M23 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: Reveal hidden contents 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
BrewManNH Posted September 20, 2011 Posted September 20, 2011 There are a few tricks I found that used text boxes in place of each cell of the list view. Other than some LV tricks, there's no native way to do that I could find. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! Reveal hidden contents I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Moderators Melba23 Posted September 20, 2011 Moderators Posted September 20, 2011 NunoBorges, How does this look? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #include <Constants.au3> #Include <GuiEdit.au3> Global $iOffset_X = 10, $iOffset_Y = 1 Global $fClick = False, $hLabel $GUI = GUICreate("Test", 500, 500) $ListView = _GUICtrlListView_Create($GUI, "Col 0|Col 1", $iOffset_X, $iOffset_Y, 480, 480) For $i = 0 To 4 $iIndex = _GUICtrlListView_AddItem($ListView, "TEST" & $i) _GUICtrlListView_AddSubItem($ListView, $iIndex, "TEST1" & $i, 1) Next _GUICtrlListView_SetColumnWidth($ListView, 0, 240) _GUICtrlListView_SetColumnWidth($ListView, 1, $LVSCW_AUTOSIZE_USEHEADER) $GUIshow = GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") ; For click on ListView While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; If a ListView was clicked If $fClick Then $aHit = _GUICtrlListView_SubItemHitTest($ListView) If $aHit[0] <> -1 Then _HighLight() EndIf $fClick = False EndIf WEnd Func _HighLight() ; Prevent resizing of columns ControlDisable($GUI, "", HWnd(_GUICtrlListView_GetHeader($ListView))) ; Get current text $sItemOrgText = _GUICtrlListView_GetItemText($ListView, $aHit[0], $aHit[1]) ; Get size of Label Local $aRect = _GUICtrlListView_GetSubItemRect($ListView, $aHit[0], $aHit[1]) ; Delete any existing Label GUICtrlDelete($hLabel) ; Cretae a new label $hLabel = GUICtrlCreateLabel($sItemOrgText, $aRect[0] + $iOffset_X + 5, $aRect[1] + $iOffset_Y, _GUICtrlListView_GetColumnWidth($ListView, $aHit[1]) - 7, $aRect[3] - $aRect[1], Default, $WS_EX_TOPMOST) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetColor(-1, 0xFFFFFF) EndFunc Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") ; Check if a ListView has sent the message If $hWndFrom = $ListView Then Switch $iCode Case $NM_CLICK ; Set flag $fClick = True EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc It needs polishing, but it proves the concept. M23 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: Reveal hidden contents 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
NunoBorges Posted September 21, 2011 Author Posted September 21, 2011 Melba23 Viva, This example is already quite good, I'll try to add the control keys ({UP} {Down}) ({LEFT} {Right}) and {TAB}, and I think that will be completed. I think I also need to use something like "_GUICtrlListView_Click SUB Item" / "_GUICtrlListView_Set SUB ItemFocused." Too bad the listview have this limitation, but go ahead. I'll start now, but there should only be ready for Christmas. On the issue of variable row height placed at # 1, I think it is best to use "GUICtrlListView_EnableGroupView." hugs Nuno
Moderators Melba23 Posted September 21, 2011 Moderators Posted September 21, 2011 NunoBorges, Glad you like it - good luck with the project. If you need any help you know where I am. M23 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: Reveal hidden contents 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
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