Jump to content
Sign in to follow this  
Mugen

GUICtrlCreateListView BkColor if disbaled?

Recommended Posts

Hi, I wonder if there is a way to change the backgound color of a Listview in it's disabled state.

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

Example()

Func Example()
    GUICreate("listview items", 220, 250, 100, 200, -1)
    GUISetBkColor(0x00151515)

    Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 10, 10, 200, 150)
    Local $idButton = GUICtrlCreateButton("Disable /enable", 45, 170, 120, 20)
    Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
    Local $iState

    GUICtrlSetColor($idListview, 0x0000FF00)
    GUICtrlSetBkColor($idListview, 0x00151515)

    GUISetState(@SW_SHOW)
    GUICtrlSetData($idItem2, "ITEM1")
    GUICtrlSetData($idItem3, "||COL33")

    $iState = 0
    GUICtrlSetState($idListview, 128)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton

                IF $iState = 0 Then
                    GUICtrlSetState($idListview, 64)
                    $iState = 1
                Else
                    GUICtrlSetState($idListview, 128)
                    $iState = 0
                EndIf



        EndSwitch
    WEnd
EndFunc

 

Share this post


Link to post
Share on other sites

Maybe you could use _GUICtrlListView_SetItemImage to mark the line with an icon (see the example script in the help file for ... an example :) )


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Share this post


Link to post
Share on other sites

There is no good way to change the background color in a disabled listview. But the usual workaround of placing the listview in a child window and then disable the child window instead of the listview works well in this situation:

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

Example()

Func Example()
    Local $hGui = GUICreate("listview items", 220, 250, 100, 200, -1)
    GUISetBkColor(0x00151515)

    Local $hChild = GUICreate( "", 200, 150, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $hGui )
    Local $idListview = GUICtrlCreateListView("col1  |col2|col3  ", 0, 0, 200, 150)
    Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview)
    Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview)
    Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview)
    GUICtrlSetColor($idListview, 0x0000FF00)
    GUICtrlSetBkColor($idListview, 0x00151515)
    GUISetState( @SW_SHOW, $hChild )
    GUISwitch( $hGui )

    Local $idButton = GUICtrlCreateButton("Disable /enable", 45, 170, 120, 20)
    Local $iState

    GUISetState(@SW_SHOW)
    GUICtrlSetData($idItem2, "ITEM1")
    GUICtrlSetData($idItem3, "||COL33")

    $iState = 0
    GUISetState( @SW_DISABLE, $hChild )
    ;GUICtrlSetState($idListview, 128)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $idButton

                IF $iState = 0 Then
                    ;GUICtrlSetState($idListview, 64)
                    GUISetState( @SW_ENABLE, $hChild )
                    $iState = 1
                Else
                    ;GUICtrlSetState($idListview, 128)
                    Local $aIndex = _GUICtrlListView_GetSelectedIndices( $idListview, True )
                    _GUICtrlListView_SetItemSelected( $idListview, $aIndex[0] ? $aIndex[1] : -1, False )
                    GUISetState( @SW_DISABLE, $hChild )
                    $iState = 0
                EndIf
        EndSwitch
    WEnd
EndFunc

When the child window becomes disabled, the listview is also disabled. But the background color does not change.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...