Jump to content
Sign in to follow this  
MerkurAlex

Latest version listview

Recommended Posts

MerkurAlex

In the help file there is something that is almost exactly like this but they both don't work in the latest version of Autoit.

#include <guiconstants.au3>
#Include <GuiListView.au3>
$gui=guicreate("test",500,500,-1,-1)
$listview=guictrlcreatelistview("test|test2",0,0,500,500)
guictrlcreatelistviewitem("test3|test4",$listview)
guictrlcreatelistviewitem("tes5|test6",$listview)
guisetstate(@SW_SHOW)

while 1
    $msg=guigetmsg()
    switch $msg
        case $gui_event_close
            Exit
        case $listview
            msgbox('','',_GUICtrlListView_GetSelectedIndices($listview)+1)
    endswitch
wend

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
MerkurAlex

cast it as an int

Call what as an int the problem is it isn't showing a msgbox when its supposed to.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
GaryFrost

Call what as an int the problem is it isn't showing a msgbox when its supposed to.

"Cast" not "Call"

#include <guiconstants.au3>
#Include <GuiListView.au3>
$gui=guicreate("test",500,500,-1,-1)
$listview=guictrlcreatelistview("test|test2",0,0,500,500)
guictrlcreatelistviewitem("test3|test4",$listview)
guictrlcreatelistviewitem("tes5|test6",$listview)
guisetstate(@SW_SHOW)

while 1
    $msg=guigetmsg()
    switch $msg
        case $gui_event_close
            Exit
        case $listview
            msgbox('','',Int(_GUICtrlListView_GetSelectedIndices($listview)))
    endswitch
wend

SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites
MerkurAlex

"Cast" not "Call"

#include <guiconstants.au3>
#Include <GuiListView.au3>
$gui=guicreate("test",500,500,-1,-1)
$listview=guictrlcreatelistview("test|test2",0,0,500,500)
guictrlcreatelistviewitem("test3|test4",$listview)
guictrlcreatelistviewitem("tes5|test6",$listview)
guisetstate(@SW_SHOW)

while 1
    $msg=guigetmsg()
    switch $msg
        case $gui_event_close
            Exit
        case $listview
            msgbox('','',Int(_GUICtrlListView_GetSelectedIndices($listview)))
    endswitch
wend
Yea i know thats not whats wrong the msgbox never shows itself read my last post.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
GaryFrost

Yea i know thats not whats wrong the msgbox never shows itself read my last post.

Click on the header of the listview, that's where your telling it to give you a msgbox.


SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites
MerkurAlex

Click on the header of the listview, that's where your telling it to give you a msgbox.

Ahh thats the reason is there a way to have it be the area where the items are not the header?

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
smashly

#include <guiconstants.au3>
#Include <GuiListView.au3>

Global $LVI[21]

$Gui = GUICreate("Listview Click",500,500,-1,-1)
$ListView = GUICtrlCreateListView("Col 1   |Col 2",0,0,500,500)
For $i = 1 To 20
    $LVI[$i] = GUICtrlCreateListViewItem("Item " & $i -1 & "|SubItem " & $i - 1,$listview)
Next
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            For $i = 1 To Ubound($LVI) -1
                If $msg = $LVI[$i] Then MsgBox(0,'',Int(_GUICtrlListView_GetSelectedIndices($ListView)))
            Next
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites
MerkurAlex

#include <guiconstants.au3>
#Include <GuiListView.au3>

Global $LVI[21]

$Gui = GUICreate("Listview Click",500,500,-1,-1)
$ListView = GUICtrlCreateListView("Col 1   |Col 2",0,0,500,500)
For $i = 1 To 20
    $LVI[$i] = GUICtrlCreateListViewItem("Item " & $i -1 & "|SubItem " & $i - 1,$listview)
Next
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            For $i = 1 To Ubound($LVI) -1
                If $msg = $LVI[$i] Then MsgBox(0,'',Int(_GUICtrlListView_GetSelectedIndices($ListView)))
            Next
    EndSwitch
WEnd
Well the problem with this is im using _GUICtrlListView_AddArray($ListView, $array)

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
Siao

NM_CLICK

(and since I predict you asking something stupid like "what is that?", see the example of _GUICtrlListView_Create() in UDFs helpfile how to work with that notification).

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites
MerkurAlex

NM_CLICK

(and since I predict you asking something stupid like "what is that", see the example of _GUICtrlListView_Create() in UDFs helpfile how to work with that notification).

Well thanks for calling me stupid this is the only problem i've had in months of using autoit and the only reason i couldn't figure it out is cause its the third time i have used listview's and the first time i've had to check this thanks though.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites
smashly

Same thing just a different way of getting the index. Should work with external added items as well.

#Include <GuiListView.au3>

Global $iDx = -1

$Gui = GUICreate("Listview Click",500,500,-1,-1)
$ListView = GUICtrlCreateListView("Col 1   |Col 2",0,0,500,500)
For $i = 0 To 19
    GUICtrlCreateListViewItem("Item " & $i & "|SubItem " & $i,$listview)
Next
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    If GUIGetMsg() = -3 Then Exit
    If $iDx <> -1 Then
        MsgBox(0, "", "Index: " & $iDx)
        $iDx = -1
    EndIf
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = GUICtrlGetHandle($ListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    If $hWndFrom = $hWndListView And $iCode = $NM_CLICK Then
        Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
        If DllStructGetData($tInfo, "Index") <> - 1 Then $iDx = DllStructGetData($tInfo, "Index")
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc
Cheers

Edit: removed the global $LVI array

Edited by smashly

Share this post


Link to post
Share on other sites
MerkurAlex

Same thing just a different way of getting the index. Should work with external added items as well.

#Include <GuiListView.au3>

Global $iDx = -1

$Gui = GUICreate("Listview Click",500,500,-1,-1)
$ListView = GUICtrlCreateListView("Col 1   |Col 2",0,0,500,500)
For $i = 0 To 19
    GUICtrlCreateListViewItem("Item " & $i & "|SubItem " & $i,$listview)
Next
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    If GUIGetMsg() = -3 Then Exit
    If $iDx <> -1 Then
        MsgBox(0, "", "Index: " & $iDx)
        $iDx = -1
    EndIf
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = GUICtrlGetHandle($ListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    If $hWndFrom = $hWndListView And $iCode = $NM_CLICK Then
        Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
        If DllStructGetData($tInfo, "Index") <> - 1 Then $iDx = DllStructGetData($tInfo, "Index")
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc
Cheers

Edit: removed the global $LVI array

I already started doing this thanks though.

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.