Jump to content

Use of a Icon in GUICtrlListView in the second column


pluto41
 Share

Recommended Posts

Hi. I want to create simple GUI with two columns. In the first column i want to show some sort of software installation comments/steps.

Then when a installation step is completed i want to show this in the second column with use of a failure / succes icon.

In the code below you see i am able to get a icon in the first column, but i need the icon to be where the 'x' now is. (the second column).

Any ideas/tips/example how this can be done ?

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
Local $introWindow = GUICreate("Test", 390, 390)
Local $listView = GUICtrlCreateListView ( "Installation Step|Progress", 15, 15, 350, 150 )
_GUICtrlListView_SetColumnWidth($listView, 0, 250)
_GUICtrlListView_SetColumnWidth($listView, 1, 50)
$itemContent = "First Software installation step" & "|" & "x"
$item = GUICtrlCreateListViewItem ( $itemContent, $listView )
GUICtrlSetImage($item, "shell32.dll", 4)
GUICtrlCreateListViewItem("Second Software installation step", $listView)
GUICtrlCreateListViewItem("Third Software installation step", $listView)
GUICtrlCreateListViewItem("Fourth Software installation step", $listView)
GUISetState(@SW_SHOW)
While 1
Local $GuiLCMMessage = GUIGetMsg()
Select
Case $GuiLCMMessage = $GUI_EVENT_CLOSE
  GUISetState (@SW_HIDE)
  ExitLoop
EndSelect
WEnd
Link to comment
Share on other sites

  • Moderators

pluto41,

As far as I know you can only get icons, checkboxes and the like in the first column. ;)

The best I could ever get was this: :D

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()

    GUICreate("Reversed Listview", 220, 250)

    Local $hListView = GUICtrlCreateListView("col1      |col2|col3", 10, 10, 200, 150, -1, $WS_EX_LAYOUTRTL) ; Reverse the ListView
    _GUICtrlListView_SetExtendedListViewStyle(GUICtrlGetHandle($hListView), $LVS_EX_CHECKBOXES)

    GUICtrlCreateListViewItem("item2|col22|col23", $hListView)
    GUICtrlCreateListViewItem("item1|col12|col13", $hListView)
    GUICtrlCreateListViewItem("item3|col32|col33", $hListView)

    GUISetState()

    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
    WEnd

EndFunc   ;==>Example

Any use? :)

M23

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

 

Link to comment
Share on other sites

For using icons in LV subitems there's more than one example in the UDF help-file :)...

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
GUICreate("ListView Set Item Image", 400, 300)
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 110)
_GUIImageList_AddIcon($hImage, @SystemDir & "shell32.dll", 131)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; Add columns
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddColumn($hListView, "Column 2", 100)
; Add items
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1")
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2",1)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1")
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2",1)
_GUICtrlListView_SetItemImage($hListView, 0, 0, 0)
_GUICtrlListView_SetItemImage($hListView, 0, 2, 1)
_GUICtrlListView_SetItemImage($hListView, 1, 1, 0)
_GUICtrlListView_SetItemImage($hListView, 1, 3, 1)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Link to comment
Share on other sites

Melba32 / Kafu thanks both very much for the quick reply.

I was just about to post here that the first post solution would be suitable for me.

Then came Kafu with his post and i almost fell of the chair :-) Very good job. I have searched for hours today for such a solution on the Internet

and in the past i have done much more searching for the same. I really learned something today.

Both very thanks for your postings.

[sOLVED]

Link to comment
Share on other sites

  • Moderators

Kafu,

And for checkboxes? :)

M23

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

 

Link to comment
Share on other sites

  • Moderators

Kafu,

the OP only asked for icons

I know - I was asking for me! :)

M23

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

 

Link to comment
Share on other sites

I know - I was asking for me!

Now I fell off my chair :) You're the ListView wiz kid Melba!

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

guinness,

But I have never managed to do this - never too late to learn! :)

M23

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

 

Link to comment
Share on other sites

Of course not :) I don't think I've ever tried incorporating checkboxes and images together. I'll get back to you if or when I find a solution.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Taking a look at the LVITEM structure the "state" member gave me something to think about.

How about creating a custom state Imagelist with checkboxes (like I do in SMF for treeview, in the source you'll find the images in .ico format) and assign the list with _GUICtrlListView_SetImageList($hWnd, $hHandle, 2) to the LV. Additionally one should write a custom wm_notifiy handler catching the clicks and changing the states...

In theory that should not be too hard... compared to other methods which come to my mind using _GUICtrlListView_GetItemRect() & _GUICtrlListView_GetSubItemRect() :)...

Link to comment
Share on other sites

Nope, state imagelist didn't work. States also can only be applied to the item as a whole and not the subitems.

But using a normal imagelist and faking checkboxes seems to work :)...

Sadly $LVS_EX_FULLROWSELECT needs to be set. Or does anyone know a style-combo which allows subitem selection?

Link to comment
Share on other sites

It's certainly a different approach and I like the checkboxes too.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

Kafu,

anyone know a style-combo which allows subitem selection?

I have been looking for that for some time. These 2 examples from previous threads on this where I tried to help out are the best I have managed: ;)

- 1. Highlighting the selected column - easy but not very good:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>

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)

For $i = 0 To 6
    GUICtrlCreateListViewItem("Col1_Lin" & $i + 1 & "|Col2_Lin" & $i + 1, $ListView1)
Next
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") 

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    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

- 2. Using an owner-drawn label to overwrite the subitem - better but not perfect:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Constants.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

If you ever find a good way to do a lot of people will be very happy - including me. :)

M23

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

 

Link to comment
Share on other sites

How about this example, based on and using UEZs excellent to include the icons :)?

3.3.6.1

_LV_Checkboxes.zip

3.3.8.0

_LV_Checkboxes.zip

Edit: Removed subitem highlighting again. Default highlighting for listviews is per row / item and implementing it per subitem is more complex than I thought. Also key movements would have been taken into account, a mechanism simulating a per subitem highlighting and tracking would have to be implemented, thus I thought removing the highlighting altogether is much more easy ;)... but I've added three functions to check, uncheck and query the states of all subitems.

Edit2: Added a new version for 3.3.8.0.

Edited by KaFu
Link to comment
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
 Share

  • Recently Browsing   0 members

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