MerkurAlex Posted January 8, 2008 Share Posted January 8, 2008 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] Link to comment Share on other sites More sharing options...
GaryFrost Posted January 8, 2008 Share Posted January 8, 2008 cast it as an int 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 More sharing options...
MerkurAlex Posted January 8, 2008 Author Share Posted January 8, 2008 cast it as an intCall 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] Link to comment Share on other sites More sharing options...
GaryFrost Posted January 8, 2008 Share Posted January 8, 2008 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. Link to comment Share on other sites More sharing options...
MerkurAlex Posted January 8, 2008 Author Share Posted January 8, 2008 "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 wendYea 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] Link to comment Share on other sites More sharing options...
GaryFrost Posted January 8, 2008 Share Posted January 8, 2008 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. Link to comment Share on other sites More sharing options...
MerkurAlex Posted January 8, 2008 Author Share Posted January 8, 2008 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] Link to comment Share on other sites More sharing options...
smashly Posted January 8, 2008 Share Posted January 8, 2008 #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 Link to comment Share on other sites More sharing options...
MerkurAlex Posted January 8, 2008 Author Share Posted January 8, 2008 #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 WEndWell 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] Link to comment Share on other sites More sharing options...
Siao Posted January 8, 2008 Share Posted January 8, 2008 (edited) 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 January 8, 2008 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
MerkurAlex Posted January 8, 2008 Author Share Posted January 8, 2008 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] Link to comment Share on other sites More sharing options...
smashly Posted January 8, 2008 Share Posted January 8, 2008 (edited) 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 January 8, 2008 by smashly Link to comment Share on other sites More sharing options...
MerkurAlex Posted January 9, 2008 Author Share Posted January 9, 2008 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 arrayI 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] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now