Jump to content

Highlighted item in a listview


er453r
 Share

Recommended Posts

Hi. I'm using new betas listviews. How can I determine which item in a listview is highlighted? (and by highlighted I mean this blueish background, see example)

not highlighted

post-19050-1195909964_thumb.jpg

highlighted

post-19050-1195909973_thumb.jpg

_GUICtrlListView_GetSelectionMark is something else. It's the striped gray border, and I'm interested in the blueish things...

And the bonus question! How can I control the resizing of the the new listviews?

Link to comment
Share on other sites

Unfortunately, both don't work.

1. Selected is something else than "highlighted".

2. GUICtrlSetResizing() , ControlMove() don't work with new betas ListViews.

1. You'll probably have to loop through each item in the listview and do a BitAnd check on _GUICtrlListView_GetItemState ($hListView, $iIndex, $LVIS_DROPHILITED)

2. WinMove

Edited by GaryFrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

How can I use WinMove on a ListView?

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Opt('MustDeclareVars', 1)

$Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

Example_External() ;use UDF built listview

Func Example_External()
    Local $GUI, $hImage, $hListView

    $GUI = GUICreate("(External) ListView Get Item State", 400, 300)
    $hListView = _GUICtrlListView_Create ($GUI, "", 2, 2, 394, 268)
    _GUICtrlListView_SetExtendedListViewStyle ($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
    GUISetState()

    ; Load images
    $hImage = _GUIImageList_Create ()
    _GUIImageList_Add ($hImage, _GUICtrlListView_CreateSolidBitMap ($hListView, 0xFF0000, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlListView_CreateSolidBitMap ($hListView, 0x00FF00, 16, 16))
    _GUIImageList_Add ($hImage, _GUICtrlListView_CreateSolidBitMap ($hListView, 0x0000FF, 16, 16))
    _GUICtrlListView_SetImageList ($hListView, $hImage, 1)

    ; Add columns
    _GUICtrlListView_AddColumn ($hListView, "Column 1", 100)
    _GUICtrlListView_AddColumn ($hListView, "Column 2", 100)
    _GUICtrlListView_AddColumn ($hListView, "Column 3", 100)

    ; Add items
    _GUICtrlListView_AddItem ($hListView, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem ($hListView, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem ($hListView, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem ($hListView, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem ($hListView, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem ($hListView, "Row 3: Col 1", 2)

    ; Get item 1 state
    _GUICtrlListView_SetItemState ($hListView, 0, $LVIS_DROPHILITED , $LVIS_DROPHILITED )
    MsgBox (4160, "Information", "Item 1 State: " & _GUICtrlListView_GetItemState ($hListView, 0, $LVIS_DROPHILITED ))
    WinMove($hListView, "", 10, 10)
    
    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_External

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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...