Sign in to follow this  
Followers 0
walle

Determent current selected Item within Listview?

8 posts in this topic




Well, haven't found the command in helpfile. Any idea?

_GUICtrlListView_GetItemState($LISTVIEW1,"",$LVIS_SELECTED) didn't work out

;Listbox, works
_GUICtrlListBox_GetText($LISTBOX1, _GUICtrlListBox_GetCurSel($LISTBOX1))

;This dosn't work.
_GUICtrlListView_GetItemText($LISTVIEW1, _GUICtrlListView_GetItemSelected($LISTVIEW1))
Look in the help file for _GUICtrlListView_GetItemSelected()

Note that there is a difference between a ListBox and a ListView. ListBox functions are not intended to work on a listView control


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

From the helpfile:

_GUICtrlListView_GetItemSelected

--------------------------------------------------------------------------------

Determines whether the item is selected

Return Value

Success: True

Failure: False

_GUICtrlListView_GetItemSelected retrieves whether the item is selected or not, not the item index.

That's probably why it ain't working, never worked with these functions so I wouldn't know. :)

Share this post


Link to post
Share on other sites

From the helpfile:

_GUICtrlListView_GetItemSelected retrieves whether the item is selected or not, not the item index.

That's probably why it ain't working, never worked with these functions so I wouldn't know. :)

You are correct. Looks like it will now be

_GUICtrlListView_GetSelectedIndices()


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

From the help:

#include <GUIConstants.au3>
#include <GuiListView.au3>

$hGui = GUICreate("Test", 200, 100)

$hListView = _GUICtrlListView_Create($hGui, "Items|SubItems", 10, 10, 180, 80, BitOR($LVS_REPORT, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $WS_CLIPSIBLINGS), $WS_EX_CLIENTEDGE)

_GUICtrlListView_AddItem($hListView, "Item1")
_GUICtrlListView_AddItem($hListView, "Item2")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

GUISetState()

Do
  $msg = GUIGetMsg ()
Until $msg = $GUI_EVENT_CLOSE

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $tNMHDR, $hWndFrom, $iCode, $tInfo, $iIndex
    
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $hWndFrom
    Case $hListView
        Switch $iCode
        Case $NM_CLICK
            $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
            $iIndex = DllStructGetData($tInfo, "Index")
            If $iIndex <> -1 Then MsgBox(0, "Message", "Item " & $iIndex & " selected")
        EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc
:) Edited by rasim

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You are correct. Looks like it will now be

_GUICtrlListView_GetSelectedIndices()

Well, that seems to work. But Im still a bit confused.

Here are three different situations. The second example

won't return the item text. Any idea why?

Returns a value, for example 1.

_GUICtrlListView_GetSelectedIndices($Listview1)oÝ÷ Ù­º¹çºYZºÚ"µÍÑÕRPÝÝY]×ÑÙ]][U^
    ÌÍÓÝY]ÌKÑÕRPÝÝY]×ÑÙ]Ù[XÝY[XÙÊ   ÌÍÓÝY]ÌJJoÝ÷ Ù­º¹ì¶¢µé¬©¡ö®¶­seôuT7G&ÄÆ7EfWuôvWDFVÕFWBb33c´Æ7GfWsÂ

Thanks for the help so far!

Edited by walle

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Well, that seems to work. But Im still a bit confused.

Here are three different situations. The second example

won't return the item text. Any idea why?

Returns a value, for example 1.

_GUICtrlListView_GetSelectedIndices($Listview1)oÝ÷ Ù­º¹çºYZºÚ"µÍÑÕRPÝÝY]×ÑÙ]][U^
    ÌÍÓÝY]ÌKÑÕRPÝÝY]×ÑÙ]Ù[XÝY[XÙÊ   ÌÍÓÝY]ÌJJoÝ÷ Ù­º¹ì¶¢µé¬©¡ö®¶­seôuT7G&ÄÆ7EfWuôvWDFVÕFWBb33c´Æ7GfWsÂ

Thanks for the help so far!

Damn AutoIt tags screwed up your code AGAIN!! I wish people would just quit using those things. I don't like the pretty colors anyway.

$Idx = Int(_GUICtrlListView_GetSelectedIndices($Listview1))
$i_Txt = _GUICtrlListView_GetItemText($Listview1, $Idx)
msgBox(0, "TEST", $i_Txt)
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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  
Followers 0