Jump to content

Listview remove column selection


Go to solution Solved by MyEarth,

Recommended Posts

Maybe i'm miss something, with custom ownerdraw if i want to remove the "selection" of the column and clear all like when you create the listview, how i can do?

;LarsJ is the author
#include <GUIListView.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $hGUI, $hListView
Global $nCurCol = -1

Global $iColDef = 0xFFFFFF
Global $iColRow = 0xC0C0C0
Global $iColColumn  = 0x0000FF ; <<<<<<<<<<<<< column color, how to reset this to 0xFFFFFF

$hGUI = GUICreate('Test', 400, 200)
$iListView = GUICtrlCreateListView('Items|SubItems', 10, 10, 280, 180, $LVS_REPORT, $WS_EX_CLIENTEDGE)
$hListView = GUICtrlGetHandle($iListView)
$iButton = GUICtrlCreateButton("Refresh", 300, 25)

For $i = 0 To 100
    _GUICtrlListView_InsertItem($hListView, 'Item' & $i)
    _GUICtrlListView_SetItemText($hListView, $i, 'SubItem' & $i, 1)
Next
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iListView
            $nCurCol = GUICtrlGetState($iListView)
            _GUICtrlListView_RedrawItems($hListView, 0, 100)
        Case $iButton
            ; refresh
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    Local $hWndFrom = DllStructGetData($tNMHDR, 'hWndFrom')
    Local $iCode = DllStructGetData($tNMHDR, 'Code')
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CUSTOMDRAW
                  Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                  Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage")
                  Switch $dwDrawStage                ; Holds a value that specifies the drawing stage
                    Case $CDDS_PREPAINT
                      ; Before the paint cycle begins
                      Return $CDRF_NOTIFYITEMDRAW    ; Notify the parent window of any item-related drawing operations
                    Case $CDDS_ITEMPREPAINT
                      ; Before painting an item
                      Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations
                    Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM )
                      ; Before painting a subitem
                      Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")
                      Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")
                      Switch $iSubItem
                        Case $nCurCol
                          If $dwItemSpec = 5 Then
                            DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", $iColRow)
                          Else
                            DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", $iColColumn)
                          EndIf
                        Case Else
                          If $dwItemSpec = 5 Then
                            DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", $iColRow)
                          Else
                            DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", $iColDef)
                          EndIf
                      EndSwitch
                      Return $CDRF_NEWFONT
                  EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by MyEarth
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...