Jump to content

Selecting the first item in a ListView, then unselecting it


c.haslam
 Share

Recommended Posts

I have a dialog with a ListView in it. I have succeeded in getting the first item to show in reverse video, as though the user selected it:

Local $FmInDirNotProj = GUICreate("Preview: jpg's in Directory but not in Project", 560, 305, 222, 279, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
Local $btnClose = GUICtrlCreateButton("Close", 312, 256, 41, 25, 0)
Local $ListView1 = GUICtrlCreateListView("Filename|Date and time", 8, 32, 357, 214)
GUICtrlSendMsg(-1, 0x101E, 0, 190)  ; set column widths
GUICtrlSendMsg(-1, 0x101E, 1, 163)
    $qPics = UBound($nuAr,1) - 1
    Local $cidVec[$qPics+1]
    For $i = 1 To $qPics
        Local $t = $nuAr[$i][$kFnam]&"|"&$nuAr[$i][$kDatTim]
        $cidVec[$i] = GUICtrlCreateListViewItem($t,$ListView1)
    Next
    _GUICtrlListView_SetItemDropHilited ($ListView1, 0)
    While 1
        $nMsg = GUIGetMsg()
        $cidIsLVitem = False
        For $i = 1 To $qPics
            If $nMsg=$cidVec[$i] Then
                $nrow = $i
                _GUICtrlListView_SetItemDropHilited ($ListView1, 0,False)
$cidIsLVitem = True
                ExitLoop
            EndIf
        Next
        If Not $cidIsLVitem Then
            Switch $nMsg
            Case $GUI_EVENT_CLOSE,$btnClose
                ExitLoop
            EndSwitch
        EndIf   
Wend

The second call to _GUICtrlListView_SetItemDropHilited() is intended to deselect the first item when the user selects another item, but it doesn't work.

How do I get this to work?

...chris

Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

I have a dialog with a ListView in it. I have succeeded in getting the first item to show in reverse video, as though the user selected it:

Local $FmInDirNotProj = GUICreate("Preview: jpg's in Directory but not in Project", 560, 305, 222, 279, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
Local $btnClose = GUICtrlCreateButton("Close", 312, 256, 41, 25, 0)
Local $ListView1 = GUICtrlCreateListView("Filename|Date and time", 8, 32, 357, 214)
GUICtrlSendMsg(-1, 0x101E, 0, 190)  ; set column widths
GUICtrlSendMsg(-1, 0x101E, 1, 163)
    $qPics = UBound($nuAr,1) - 1
    Local $cidVec[$qPics+1]
    For $i = 1 To $qPics
        Local $t = $nuAr[$i][$kFnam]&"|"&$nuAr[$i][$kDatTim]
        $cidVec[$i] = GUICtrlCreateListViewItem($t,$ListView1)
    Next
    _GUICtrlListView_SetItemDropHilited ($ListView1, 0)
    While 1
        $nMsg = GUIGetMsg()
        $cidIsLVitem = False
        For $i = 1 To $qPics
            If $nMsg=$cidVec[$i] Then
                $nrow = $i
                _GUICtrlListView_SetItemDropHilited ($ListView1, 0,False)
$cidIsLVitem = True
                ExitLoop
            EndIf
        Next
        If Not $cidIsLVitem Then
            Switch $nMsg
            Case $GUI_EVENT_CLOSE,$btnClose
                ExitLoop
            EndSwitch
        EndIf   
Wend

The second call to _GUICtrlListView_SetItemDropHilited() is intended to deselect the first item when the user selects another item, but it doesn't work.

How do I get this to work?

...chris

Can you post something we could run?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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...