Sign in to follow this  
Followers 0
dynamitemedia

Strange Behavior of Listview in all Tabs

5 posts in this topic

I have a List view i loaded into a Tab...

once loaded its showing in all Tabs...

here is my full code :

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <Process.au3>
#include <Constants.au3>
#include <String.au3>
#include <Array.au3>


$Form1 = GUICreate("0", 601, 401, 186, 114)


Global $favoritesPath = @ScriptDir & "\listings\favorites.ini"
; Set flag to indicate double click in ListView




; --------------   Channel Guide Tab --------------


$plugins = GUICtrlCreateTab(8, 8, 580, 336)
$Guide = GUICtrlCreateTabItem("Channel Guide ")




; Need to open XML to display
$Button10 = GUICtrlCreateButton("Open XML", 32, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


; Refreshes the XML opened up 
$Button12 = GUICtrlCreateButton("Refresh", 120, 56, 75, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


; add the XML from above 
$List1 = GUICtrlCreateListView("ID|Name", 31, 89, 529, 230)


; ----------------    Favorites Tab    --------------
$TabSheet2 = GUICtrlCreateTabItem("Favorites")


; Adds dialog 
GUICtrlCreateLabel("Add Video feed To Your Favorites", 144, 64, 287, 26)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")


; Add video Name
$Label1 = GUICtrlCreateLabel(" Name :", 72, 112, 67, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input1 = GUICtrlCreateInput("", 144, 112, 361, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")


; Add quality
$Label2 = GUICtrlCreateLabel("URL :", 88, 152, 43, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input2 = GUICtrlCreateInput("", 144, 152, 361, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")


; Add quality
$Label3 = GUICtrlCreateLabel("Quality :", 72, 192, 59, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
$Input3 = GUICtrlCreateInput("", 144, 192, 361, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")


; Adds dialog
$Label4 = GUICtrlCreateLabel("NOTE:  and is set to 'High'", 56, 280, 483, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")


; Now lets save to favorites XML  
$Button9 = GUICtrlCreateButton("Save", 432, 224, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")


; clear 
$Button14 = GUICtrlCreateButton("Clear", 346, 224, 75, 25)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")




; ------------    Plugins Tab --------------------
$TabSheet3 = GUICtrlCreateTabItem("Plugins")


; gets Listing of files in plugin folder BY  extension 
$Label11 = GUICtrlCreateLabel("Available Plugins", 32, 68, 185, 18)
GUICtrlSetFont(-1, 12, 400, 0, "Arial") 


$List2 = GUICtrlCreateList("", 32, 88, 521, 174)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")


Local $FileList = _FileListToArray("plugins", "*.bat*")


For $i = 1 To $FileList[0]
        GUICtrlSetData($List2, RemoveExt(GetFileName($FileList[$i])))
    Next


; Gets updates all Plugins in plugins folder 
$Button11 = GUICtrlCreateButton("Refresh Plugins", 456, 288, 90, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


; Launc website 
$Button13 = GUICtrlCreateButton("Get More Plugins", 360, 288, 90, 25)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")


; Settings page
$TabSheet1 = GUICtrlCreateTabItem("Settings")
GUICtrlCreateGroup(" Program Settings ", 24, 64, 545, 115)


; add your token here
GUICtrlCreateLabel("Token", 32, 80, 35, 17)
GUICtrlCreateInput("", 32, 96, 505, 21)


; add IP Port for streamer
$Labe20 = GUICtrlCreateLabel("Port # ( Default is 8080)", 32, 128, 116, 17)
GUICtrlCreateInput("8080", 32, 144, 121, 21)


; streaming preference
Local $idStream = GUICtrlCreateCombo("Protocol", 184, 144, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Label10 = GUICtrlCreateLabel("Preferred Streaming Protocol", 184, 128, 139, 17)
GUICtrlSetData($idStream , "RTMP|HLS", "RTMP")


; Now Lets save to programSettings.ini
$Button7 = GUICtrlCreateButton("Save", 456, 140, 75, 25)


; create Group Video Settings


GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup(" Video Settings ", 24, 216, 545, 115)


; FPS 
Local $idFPS = GUICtrlCreateCombo("", 32, 256, 95, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Label5 = GUICtrlCreateLabel("FPS", 32, 240, 24, 17)
GUICtrlSetData($idFPS, "15|24.97|25|29.97|30", "15")


; Width
Local $idWidth = GUICtrlCreateCombo("", 136, 256, 95, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Label6 = GUICtrlCreateLabel("Width", 136, 240, 32, 17)
GUICtrlSetData($idWidth, "320|640|720|1080", "320")


; Height
Local $idHeight = GUICtrlCreateCombo("", 240, 256, 95, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Label7 = GUICtrlCreateLabel("Height", 240, 240, 35, 17)
GUICtrlSetData($idHeight, "240|480|1080|1920", "240")


; Video Bit Rate
Local $idVBR = GUICtrlCreateCombo("", 344, 256, 100, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Label8 = GUICtrlCreateLabel("Video Bit Rate", 344, 240, 72, 17)
GUICtrlSetData($idVBR, "300|600|800|1000|1500|2000", "300")


; Audio Bit Rate
Local $idABR = GUICtrlCreateCombo("", 456, 256, 95, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Label9 = GUICtrlCreateLabel("Audio Bit Rate", 456, 240, 72, 17)
GUICtrlSetData($idABR, "96|128|192|256", "96")


GUICtrlCreateGroup("", -99, -99, 1, 1)
; Now Lets save to videoSettings.ini
$Button8 = GUICtrlCreateButton("Save", 456, 288, 75, 25)
GUICtrlCreateTabItem("")


; --------------         ends settings page    ----------------------------




; -------------   Buttons on Bottom of Tabs ----------------------------
$Button1 = GUICtrlCreateButton("Watch", 14, 360, 75, 25)




$Button2 = GUICtrlCreateButton("Stop All", 94, 360, 75, 25)




$Button3 = GUICtrlCreateButton("Record", 336, 360, 75, 25)




$Button5 = GUICtrlCreateButton("Stream", 416, 360, 75, 25)




$Button6 = GUICtrlCreateButton("Add to favorites", 496, 360, 91, 25)




; ------------------  Functions  ---------------------------


Func RemoveExt($Input)
Local $ExtArray = StringSplit($Input, ".")
Return StringReplace($Input, "." & $ExtArray[$ExtArray[0]], "", -1)
EndFunc


Func RemoveExtRegExp($Input)
Return StringRegExpReplace($Input, "\.[^.]*$", "")
EndFunc


Func GetFileName($Input)
Local $PathArray = StringSplit($Input, "\/")
Return $PathArray[$PathArray[0]]
EndFunc


Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam)
If @error Then Return 0
$code = DllStructGetData($tagNMHDR, 3)
If $wParam = $List1 And $code = -3 And _GUICtrlListView_GetSelectedCount($List1) > 0 Then ;Put code here to deal with the double click
$col_value = _GUICtrlListView_GetItemText($List1, _GUICtrlListView_GetNextItem($List1), 0)


$xml=FileRead($xmlName)
$sSearch=_StringBetween($xml,"ID='" & $col_value & "'","/>")
$sResult=_ArrayToString($sSearch,"")


Local $splitXML = StringSplit($sResult, "'")
For $i = 1 To $splitXML[0]
Next
$rURL = $splitXML[2]
$rName = $splitXML[4]
$rQuality = $splitXML[6]
ConsoleWrite($rQuality & @CRLF)
    
If $rQuality = ' quality=' then
$realQuality =  $splitXML[7]
msgbox(0, "Quality is 7", $realQuality & @CRLF)
Else
$realQuality =  $splitXML[6]
msgbox(0, "Quality is 6",  $realQuality & @CRLF)
EndIf
endif
Return $GUI_RUNDEFMSG
EndFunc


; --------------  button functions ----------------------------


GUISetState(@SW_SHOW)


; Look for double clicks
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")




While 1
$MSG = GUIGetMsg()
Select
Case $MSG = $GUI_EVENT_CLOSE
Exitloop


Case $MSG = $Button1 ; watch


Case $MSG = $Button2 ; Stop all Button




Case $MSG = $Button3 ; recording Button




Case $MSG = $Button5 ; streaming Button


Case $MSG = $Button6 ; save to favorites Button


$col_value = _GUICtrlListView_GetItemText($List1, _GUICtrlListView_GetNextItem($List1), 1)
msgbox (0, "You Selected This Video Feed", $col_value) 
; FileWriteLine("listings\favorites.xml",'')


Case $MSG = $Button7 ; save to programSettings.ini




Case $MSG = $Button8 ; save to videoSettings.ini 


Case $MSG = $Button9 ; save to favroites.xml 
$URL = GUICtrlRead($Input2)
$name = GUICtrlRead($Input1)
$quality = GUICtrlRead($Input3)
$favXML = "listings\favs.xml"


If GuiCtrlRead($Input1) = "" Then
MsgBox (0,"Empty", "Name can't Be empty, Try again")
ElseIf GuiCtrlRead($Input2) = "" Then
MsgBox (0,"Empty", "URL can't Be empty, Try again") 
ElseIf GuiCtrlRead($Input3) = "" Then
MsgBox (0,"Empty", "Quality can't Be empty, Try again") 
Else
Local $iCountLines = _FileCountLines($favXML) ; Retrieve the number of lines in the current script.
$ID = $iCountLines + 1


FileWriteLine($favXML, "<channel ID='" & $ID & "' url='" & $URL & "' name='" & $name & "' quality='" & $quality & "'/>""")


GUICtrlSetData($Input1, "")
GUICtrlSetData($Input2, "")
GUICtrlSetData($Input3, "")


; Run("listings\createFavorites.bat")
MsgBox(0, "", "Saved to Favorites!")
EndIf


Case $MSG = $Button10 ; Need to open XML to display 


$openXML = FileOpenDialog("Choose a file", @ScriptDir & "\listings", "XML (*.xml)", 1 + 4 )
If @error Then
MsgBox(0,"","No File(s) chosen")
Else


$openXML = StringReplace($openXML, "|", @CRLF)
Dim $xmlName = $openXML


MsgBox(0,"IpTvMyWay v2.0","You chose " & $xmlName)


_GUICtrlListView_DeleteAllItems($List1)
$sRead = FileRead($openXML)


Global $aID = StringRegExp($sRead, "(?i)ID='(.*?)'", 3)
Global $aName = StringRegExp($sRead, "(?i)name='(.*?)'", 3)
Global $aQuality= StringRegExp($sRead, "(?i)quality='(.*?)'", 3)
Global $aUrl= StringRegExp($sRead, "(?i)url='(.*?)'", 3)




$iUbound = UBound($aID)
If UBound($aName) > $iUbound Then $iUbound = UBound($aName)


$List1 = GUICtrlCreateListView("ID|Name",31, 89, 529, 230)


For $i = 0 To $iUbound - 1
$strData = ""
If UBound($aID) > $i Then $strData &= $aID[$i]
If UBound($aName) > $i Then $strData &= "|" & $aName[$i]
_GUICtrlListView_SetColumnWidth($List1, 0, 40)
_GUICtrlListView_SetColumnWidth($List1, 1, 440)
GUICtrlCreateListViewItem($strData, $List1)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Next
EndIf




Case $MSG = $Button11 ; Gets updates all Plugins in plugins folder 


Case $MSG = $Button12 ; Refreshes the XML opened up 


_GUICtrlListView_DeleteAllItems($List1)
$sRead = FileRead($openXML)


Global $aID = StringRegExp($sRead, "(?i)ID='(.*?)'", 3)
Global $aName = StringRegExp($sRead, "(?i)name='(.*?)'", 3)
Global $aQuality= StringRegExp($sRead, "(?i)quality='(.*?)'", 3)
Global $aUrl= StringRegExp($sRead, "(?i)url='(.*?)'", 3)




$iUbound = UBound($aID)
If UBound($aName) > $iUbound Then $iUbound = UBound($aName)


$List1 = GUICtrlCreateListView("ID|Name", 31, 89, 529, 230)


For $i = 0 To $iUbound - 1
$strData = ""
If UBound($aID) > $i Then $strData &= $aID[$i]
If UBound($aName) > $i Then $strData &= "|" & $aName[$i]
_GUICtrlListView_SetColumnWidth($List1, 0, 40)
_GUICtrlListView_SetColumnWidth($List1, 1, 440)
GUICtrlCreateListViewItem($strData, $List1)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
Next


Case $MSG = $Button13 ; launches website


Case $MSG = $Button14 ; clears favorites
GUICtrlSetData($Input1, "")
GUICtrlSetData($Input2, "")
GUICtrlSetData($Input3, "")
MsgBox(0, "", "Form Cleared!")


EndSelect
Wend


; Deregister "Click on ListView function"
GUIRegisterMsg($WM_NOTIFY, "")

i am sure it has something to do with setting "focus" or something like that but i do not see anything like this in the forum.

Thank you

 

Share this post


Link to post
Share on other sites



You created the Listview $list1 twice, once in the Channel Guide tab creation section and again in your message loop.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

i did that so i could load XML when open button was clicked.

is there another way i could do that?  when i took out the list1 on bottom it didn't load and if caused an error when i took it out in channel guide

thank you

Share this post


Link to post
Share on other sites

Just delete all the items, as you do, and then just create new listview items using the original listview. The way you're doing it now, you'r creating not 1 a limitless number of listviews in the same GUI without deleting any of the previous ones. There's no need to recreate the listview, as it already exists and in the correct tab, just use the one you already created at the start.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

This worked great thanks!   really starting to like programming with this... Much better than Bat files!  so many options

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

  • Similar Content

    • Daka
      By Daka
      I know there are listbox and listview, but now I have?
      here is the video of infowindow 
      I tried to read mouse selection like for listbox:
      $listWindow = "[CLASS:TFormResearchGR]" $topicsList = "[CLASS:TMWrapper; INSTANCE:255]" WinWait($listWindow, "", 60) $hdlWindow = WinGetHandle($listWindow) $hdlList = ControlGetHandle($hdlWindow, "", $topicsList) _GUICtrlListBox_ClickItem($hdlList, 0, "left") $countOfList = _GUICtrlListBox_GetCount($hdlList) ConsoleWrite("Count of list: " & $countOfList & @LF) count of list is not working.
      I realiezed that there are difference between listbox and listview, but this is something different.
      and till now I never saw that you can go inside with infotool and also get instances.
       
      so Im confused how to get the list number and the names of selection?
    • AndyS19
      By AndyS19
      I have a listview with 3 columns and I want to set the 3rd column's color based on the item's 'Param' value, but even though I set up for the 3rd column, the entire row always gets the color.
      My test code is below, but here is the pertinent code:
      Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $iDrawStage, $tCustDraw $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam) $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case BitOR(0, $CDDS_ITEMPREPAINT) ;, $CDDS_SUBITEM) setItemColor($tCustDraw, $hWndFrom) Return $CDRF_NOTIFYSUBITEMDRAW EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func setItemColor($tCustDraw, $hWnd) Local $iIndex, $color, $iSubitem $iIndex = DllStructGetData($tCustDraw, 'dwItemSpec') ; item number $color = _GUICtrlListView_GetItemParam($hWnd, $iIndex) $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') ; Here, I want to only change the color of the 3rd col, and not the 1st and 2nd cols DllStructSetData($tCustDraw, 'iSubItem', 2) ; always use the 3rd column (the 'sample' col) logmsg("+++: setItemColor($tCustDraw, 0x" & Hex($hWnd) & ") entered ... " _ & ", $iIndex = " & $iIndex & ", $iSubItem = " & $iSubitem & ", $color = " & Hex($color)) DllStructSetData($tCustDraw, 'clrText', $color) ; set the Text color DllStructSetData($tCustDraw, 'clrTextBk', bitnot($color)) ; set the background color EndFunc ;==>setItemColor Func logmsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logmsg
      Here is the full test code:
      #include-once ;#cs #NoTrayIcon #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_UseX64=N Opt("GUICloseOnESC", 1) ; ESC closes GUI? (0 = no, 1 = yes) Opt("GUIOnEventMode", 1) ; Change to OnEvent mode Opt('MustDeclareVars', 1) OnAutoItExitRegister("_test_exit") Opt("GUIEventOptions", 1) ;0=default, 1=just notification, 2=GuiCtrlRead tab index Opt("WinTitleMatchMode", -2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase #include <GuiListBox.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ColorConstants.au3> Global $__MCP_obj, $__MCP_GUI_hWnd, $idListView, $hListView Global $hMainWin test() Exit Func test() $hMainWin = GUICreate("Test window", 120, 100, @DesktopWidth / 2, -1) GUICtrlCreateButton("Hwnd", 10, 10, 40, 20) GUICtrlSetOnEvent(-1, "handle_1stTEST_btn") GUICtrlCreateButton("ID", 50, 10, 40, 20) GUICtrlSetOnEvent(-1, "handle_2ndTEST_btn") GUISetOnEvent($GUI_EVENT_CLOSE, "_test_exit") GUISetState(@SW_SHOW) While (1) Sleep(17) WEnd EndFunc ;==>test Func _myColorPicker($obj) logmsg("+++: $obj = 0x" & Hex($obj) & @CRLF) Local $flags = 0 Local $ww, $wh, $x, $y, $w, $h $__MCP_obj = $obj $ww = 350 $wh = 500 $x = 200 $y = 150 $__MCP_GUI_hWnd = GUICreate("myColorPicker", $ww, $wh, $x, $y, $flags) $x = 10 $y = 10 $w = 150 $h = 20 GUICtrlCreateButton("Set caller's color", $x, $y, $w, $h) GUICtrlSetOnEvent(-1, "__MCP_handle_SetColor_btn") $y += $h + 5 $w = $ww - 25 $h = $wh - 100 $idListView = GUICtrlCreateListView("", $x, $y, $w, $h, -1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListView = GUICtrlGetHandle($idListView) $x = $ww / 2 - 50 $y = $wh - 60 $w = 100 $h = 25 GUICtrlCreateButton("Quit Popup", $x, $y, $w, $h) GUICtrlSetOnEvent(-1, "__MCP_handle_QUIT_btn") GUICtrlSetFont($idListView, 8.5, -1, -1, "courier new") _GUICtrlListView_AddColumn($idListView, "Name", 100) _GUICtrlListView_AddColumn($idListView, "Value", 100) _GUICtrlListView_AddColumn($idListView, "Sample", 100) _GUICtrlListView_SetColumnWidth($idListView, 0, 100) _GUICtrlListView_SetColumnWidth($idListView, 1, 80) logmsg("+++: $idListView = " & $idListView) logmsg("+++: $hListView = 0x" & Hex($hListView)) __MCP_populateListView($hListView) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW, $__MCP_GUI_hWnd) EndFunc ;==>_myColorPicker Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Local $hWndFrom, $iCode, $tNMHDR $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $iDrawStage, $tCustDraw $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $ilParam) $iDrawStage = DllStructGetData($tCustDraw, 'dwDrawStage') Switch $iDrawStage Case BitOR(0, $CDDS_ITEMPREPAINT) ;, $CDDS_SUBITEM) setItemColor($tCustDraw, $hWndFrom) Return $CDRF_NOTIFYSUBITEMDRAW EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func setItemColor($tCustDraw, $hWnd) Local $iIndex, $color, $iSubitem $iIndex = DllStructGetData($tCustDraw, 'dwItemSpec') ; item number $color = _GUICtrlListView_GetItemParam($hWnd, $iIndex) $iSubitem = DllStructGetData($tCustDraw, 'iSubItem') ; Here, I want to only change the color of the 3rd col, and not the 1st and 2nd cols DllStructSetData($tCustDraw, 'iSubItem', 2) ; always use the 3rd column (the 'sample' col) logmsg("+++: setItemColor($tCustDraw, 0x" & Hex($hWnd) & ") entered ... " _ & ", $iIndex = " & $iIndex & ", $iSubItem = " & $iSubitem & ", $color = " & Hex($color)) DllStructSetData($tCustDraw, 'clrText', $color) ; set the Text color DllStructSetData($tCustDraw, 'clrTextBk', bitnot($color)) ; set the background color EndFunc ;==>setItemColor Func logmsg($msg, $lnum = @ScriptLineNumber) ConsoleWrite("+++:" & $lnum & ": " & $msg & @CRLF) EndFunc ;==>logmsg Func __MCP_exit() GUIDelete($__MCP_GUI_hWnd) EndFunc ;==>__MCP_exit Func __MCP_handle_SetColor_btn() If (IsHWnd($__MCP_obj)) Then GUISetBkColor($COLOR_BLUE, $__MCP_obj) Else GUICtrlSetBkColor($__MCP_obj, $COLOR_BLUE) EndIf EndFunc ;==>__MCP_handle_SetColor_btn Func __MCP_populateListView($hWnd) Local $text, $parts, $iIndex Local Static $aItems[] = [ _ "BLACK | " & $CLR_BLACK & "|" & "", _ "BLUE | " & $CLR_BLUE & "|" & "", _ "RED | " & $CLR_RED & "|" & "", _ "WHITE | " & $CLR_WHITE & "|" & "", _ "YELLOW | " & $CLR_YELLOW & "|" & "" _ ] _GUICtrlListView_BeginUpdate($hWnd) _GUICtrlListView_DeleteAllItems($hWnd) For $ndx = 0 To UBound($aItems) - 1 $text = $aItems[$ndx] $parts = StringSplit($text, "|", 2) $parts[0] = StringStripWS($parts[0], 3) $parts[2] = StringStripWS($parts[2], 3) $iIndex = _GUICtrlListView_AddItem($hWnd, $parts[0], -1, $parts[1]) _GUICtrlListView_AddSubItem($hWnd, $iIndex, Hex($parts[1]), 1) _GUICtrlListView_AddSubItem($hWnd, $iIndex, $parts[0], 2) Next _GUICtrlListView_EndUpdate($hWnd) EndFunc ;==>__MCP_populateListView Func __MCP_handle_QUIT_btn() GUIDelete($__MCP_GUI_hWnd) EndFunc ;==>__MCP_handle_QUIT_btn Func handle_1stTEST_btn() _myColorPicker($hMainWin) EndFunc ;==>handle_1stTEST_btn Func handle_2ndTEST_btn() _myColorPicker(@GUI_CtrlId) EndFunc ;==>handle_2ndTEST_btn Func _test_exit() Exit EndFunc ;==>_test_exit  
    • nacerbaaziz
      By nacerbaaziz
      Hello guys
      Today I'll give you three functions to manage the list View items
      These functions will help you to do some works in your list view items
      1. list view Read
      To get the selected item text  
      2. listView_checke
      To checke an item
      3. isListViewChecked
      To see if the item is checked
      All of these functions will be illustrated by the following example
      You can download the include file from the link below
      Now with the example
      #include <easy_listView_functions.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> Example() Func Example()  Local $idListview  GUICreate("ListView Get Item Checked State", 1000, 700)  $idListview = GUICtrlCreateListView("", 50, 30, 250, 120, 50)  _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) ; Add items $item1 = GUICtrlCreateListViewItem("item1", $idListview) $item2 = GUICtrlCreateListViewItem("item2", $idListview) _listview_Checke($idListview, "item1") $btn = GUICtrlCreateButton("&read", 100, 150, 50, 50) $btn2 = GUICtrlCreateButton("&if checked", 100, 200, 100, 50)  GUISetState(@SW_SHOW) while 1 switch GUIGetMSG() case $GUI_EVENT_CLOSE  GUIDelete() exit case $btn $read = _ListView_read($idListView) if $read then msgBox(0, "read listview", $read) else msgBox(0, "read listview", "no text ditected") endIf case $btn2 if _isListviewChecked($idListView, "item1") then msgBox(0, "get", "the item is checked") else msgBox(0, "get", "the item isn't checked") endIf endSwitch wend EndFunc   ;==>Example
       
      easy_listView_functions.au3
    • dascondor
      By dascondor
      So I having issues with this GUI/Listview. My main GUI works like it needs to but the ListView GUIs don't. The exit buttons do not work on them and om have a hard time getting them to work. And I'm trying to make the  listview GUI resizeable. But I'm not sure how to fix either of these issues any thoughts.
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <ScreenCapture.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <ListviewConstants.au3> #include 'MultiPing.au3' Opt("GUIOnEventMode", 1) #Region ;Declares ; Reads text file for the base list of IP's Global $aBase_IPlist = _FileReadToArray_mod(".\IP_List.txt") Global $replace2 = "Second" Global $replace3 = "Thrid" ;Global $userdata1 = GUICtrlRead($data1) ;Global $userdata2 = GUICtrlRead($data2) Global $savefolder = "C:\Users\" Global $paths = "\Desktop\PingChecks" Global $1stpaths = "\~~~Store" Global $2ndpaths = "~~~" Global $results = FileExists($savefolder & @UserName & $paths) ;Global $foldercheck = FileExists($savefolder & @UserName & $paths & $1stpaths & $userdata1 & $userdata2 & $2ndpaths) ;Global $savefile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\" #EndRegion ;Declares #Region ### START Koda GUI section ### Form= $IPMonkey = GUICreate("IP Monkey", 573, 254, -1, -1) GUISetIcon("C:\Users\Dlex\Pictures\monkeyicon.ico", -1) GUISetFont(16, 800, 0, "Arial") GUISetBkColor(0xFFFFFF) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") $data1 = GUICtrlCreateInput("1", 184, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetColor(-1, 0x000000) $data2 = GUICtrlCreateInput("23", 280, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER)) GUICtrlSetColor(-1, 0x000000) $GOButton = GUICtrlCreateButton("GO", 80, 192, 75, 25) GUICtrlSetFont(-1, 10, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetTip(-1, "Runs A Live Continuous Ping" & @CRLF & _ "Until Told Other Wise") GUICtrlSetOnEvent(-1, "GOButtonClick") $quickscan = GUICtrlCreateButton("Quick Scan", 224, 192, 107, 25) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlSetOnEvent(-1, "quickscanClick") GUICtrlSetTip(-1, "Quickly Scans, Then Saves" & @CRLF & _ "Results In Your 'PingChecks' " & @CRLF & _ "Folder Under Your Store Number Folder") Global $exitbutton = GUICtrlCreateButton("Exit", 416, 192, 75, 25) GUICtrlSetFont(-1, 12, 800, 0, "Arial") GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetTip(-1, "What Do You Think This Button Does?") GUICtrlSetOnEvent(-1, "exitbuttonClick") $titlebar = GUICtrlCreateLabel("IP Monkey", 16, 120, 107, 28) GUICtrlSetColor(-1, 0x000000) $Pic1 = GUICtrlCreatePic("C:\Users\Dlex\Pictures\monkeyicon-0.jpg", 16, 16, 100, 100) GUICtrlSetOnEvent(-1, "Pic1Click") $infobutton = GUICtrlCreateButton("?", 536, 8, 27, 25) GUICtrlSetColor(-1, 0x000000) GUICtrlSetBkColor(-1, 0xFF8000) GUICtrlSetTip(-1, "Unsure what to do?" & @CRLF & _ "This will get give you " & @CRLF & _ "the help for IP Monkey") GUICtrlSetOnEvent(-1, "infobuttonClick") $Whatstorelabel = GUICtrlCreateLabel("What Store?", 208, 56, 130, 28) GUICtrlSetColor(-1, 0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ;ping gui ; ------ pinger GUI ------------------- Global $StopPing = 0 Local $Win_X = 1200, $Win_Y = 880 ; dimension of window Global $PingGui = GUICreate("IP Monkey", $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") Global $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) $button1 = GUICtrlCreateLabel("Hit Exit To Quit", 10, $Win_Y - 25, $Win_X - 20, 20, -1,$ES_CENTER) GUICtrlSetFont(-1, 10, 800) GUICtrlSetTip(-1, "exit") GUICtrlSetOnEvent(-1, 'SpecialEvents') GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) GUISetState(@SW_HIDE) ; hidden at startup ; --------- end of pinger gui ------------- #EndRegion ;ping gui ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) While 1 Sleep(100) WEnd Func exitbuttonClick() MsgBox(0,'0','0') Exit EndFunc ;==>exitbuttonClick Func GOButtonClick() $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) ; pass the wanted new octet replace_And_Go($userdata1, $userdata2) ; generate a list of new IP and Go EndFunc ;==>GOButtonClick Func infobuttonClick() EndFunc ;==>infobuttonClick Func Pic1Click() EndFunc ;==>Pic1Click Func quickscanClick() $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) replace_And_Go2($userdata1, $userdata2) EndFunc ;==>quickscanClick Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE _button1() Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE Case @GUI_CtrlId = $GUI_EVENT_RESTORE Case @GUI_CtrlId = $GUI_EVENT_MAXIMIZE EndSelect EndFunc ;==>SpecialEvents #Region ; Main_GO/Replace_and_GO #cs ############################## second script ############################################# ; this is to ping continuously a list of IP addresses, get and display ping result "live" ; it simulates the dos "ping -t" command but performed simultaneously on many IP ; presenting the results in a ListView highlighting not responding devices with a red box #ce Func replace_And_Go($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPMonkey) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger Main_GO($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPMonkey) EndFunc ;==>replace_And_Go Func Main_GO($IPlist) HotKeySet("{esc}", "exitbuttonClick") $StopPing = 0 ; $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's ; ; the above command, it loads in the $IPlist array the values contained in the file IP_List.txt ; values in the file should be separated by a semicolon, something like in the following example: ; ; hostname1;192.168.0.1 ; hostname2;192.168.0.5 ; hostnameX;10.59.7.200 ; etc.... ; ; if values in the file are not separated by a semicolon, but another char is used, for example a comma, ; then just pass it as second parameter of the function: $IPlist = _FileReadToArray_mod(".\IP_List.txt", ",") ; _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_DeleteAllItems($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) While Not $StopPing ; 1 ; continuously ping addresses of the previously loaded file (IP_List.txt) Sleep(10) ; ; $IPlist is the array loaded with all the IP to be pinged (a 2d array in this case) ; | ; | 1 means the IP are in the second column of the $IPlist array (first colun is nr. 0) ; | | ; | | +--> 0 means return back an array loaded with results from all pinged addresses (responding and not responding) ; | | | if you use 1 then only responding addresses are loaded in the returned array [default] ; | | | if you use 2 then only NOT responding addresses are loaded in the returned array ; | | | In this case we do not need an array to be returned, we only need to perform all pings and pass results ; | | | directly (on the fly) to the "_refresh" callback function that will refresh the listview ; | | | ; | | | 0 means NO lookup name resolution must be performed ; | | | | ; | | | | +--> this is the callback function to be called for each pinged address each time the ping has finished ; | | | | | (see the MultiPing.au3 file for info on all passed params) ; | | | | | 6 parameters are passed to this function, but only 2 are used by the called function in this case: ; | | | | | [4] roundtrip of the responding ping or -1 if IP is down ; | | | | | [5] Index (position) of this IP within the caller's passed array ; | | | | | ; v v v v v _nPing($IPlist, 1, 0, 0, "_refresh") WEnd EndFunc ;==>Main_GO #EndRegion ; Main_GO/Replace_and_GO #Region ; QuickScan/Replace_and_GO2 Func replace_And_Go2($s_2, $s_3) ; Create a new array wit a new list of IP according to passed second and third octet Local $aNew_IPlist = $aBase_IPlist For $i = 0 To UBound($aNew_IPlist) - 1 $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3) Next GUISetState(@SW_HIDE, $IPMonkey) GUISetState(@SW_SHOW, $PingGui) ; pass the new list to the pinger QuickRun($aNew_IPlist) GUISetState(@SW_HIDE, $PingGui) GUISetState(@SW_SHOW, $IPMonkey) EndFunc ;==>replace_And_Go2 Func QuickRun($IPlist) $userdata1 = GUICtrlRead($data1) $userdata2 = GUICtrlRead($data2) HotKeySet("{esc}", "_button1") Local $Win_X = 1200, $Win_Y = 880 ; dimension of window $PingGui = GUICreate("IP Monkey" & "~~~" & @UserName & "~~~" & "Store" & $userdata1 & $userdata2 & "~~~" & @MON & "." & @MDAY & "." & @YEAR & "~~~" & @HOUR & "." & @MIN, $Win_X, $Win_Y, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui) $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40) GUICtrlSetFont(-1, 8) GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP) ; Generate colored square images $hImage = _GUIImageList_Create(30, 30) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green _GUICtrlListView_SetImageList($listview, $hImage, 0) $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20) GUICtrlSetTip(-1, "End of program") GUICtrlSetOnEvent(-1, "exitbuttonClick") GUISetState(@SW_SHOW) ;~ $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's _GUICtrlListView_BeginUpdate($listview) _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView _GUICtrlListView_EndUpdate($listview) ;While 1 ; perform Pings and update ListView by the "_refresh" callback function $aFinalResult = _nPing($IPlist, 1, 0, 0, "_refresh") ;~ _ArrayDisplay($aFinalResult) ;DirCheck() EndFunc ;==>QuickRun #EndRegion ; QuickScan/Replace_and_GO2 #Region ; Misc Funcs (network) Func _refresh($Params) ; this receive ping results and displays them in the ListView _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow Sleep(50) ; a little wait If $Params[4] = -1 Then ; Device not responding to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item Else ; Device responds to ping _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN EndIf EndFunc ;==>_refresh Func _button1() ; Button 1 clicked ;~ $StopPing = 1 Exit EndFunc ;==>_button1 #EndRegion ; Misc Funcs (network)  
      MultiPing.au3
      IP_List.txt
    • elsemieni
      By elsemieni
      Hey hello.
      I came here with maybe too specific questions about uncommon things, but as people says, I don't lose anything trying to asking here 
      There's long time that I have a little "experimental" idea: Use windows desktop and it icon system like old videogame consoles (where "sprites" are used to draw things on screen, can be manipulated/animated to make interesting things happen). Some of that inspiration came from another experiments from demoscene.
      Researching the possibilities of doing something like that (maybe not so intense) I found that the Windows Desktop uses a GuiListView to show and arrange icons (and of course, AutoIt provides UDF's for that  ). So, I'm used that UDF to create dummy icons (not putting files on Desktop, just modifiying the "GUI layer" of desktop for put non-working icons), setting custom values like coordinates, name and Icon (from a list of loaded icons in the GuiListView).  As you can see in next image works well in Windows XP... even in Windows 95 (that's not the case from Windows Vista to 10, but I already posted another question here about that... anyways, for now I'm working that with a isolated XP machine... sigh).

      Another video doing an animation with that:
      How I make that custom icons? Here:
      $hWnd = ControlGetHandle("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]") $newItem = _GUICtrlListView_AddItem ( $hWnd, "TEST", 32 ) ; with an icon of index 32 _GUICtrlListView_SetItemPosition ( $hWnd, $newItem, 300, 300 ) ; set some example property. Put in X=300 Y=300 Okay, so the next phase was changing the icons with custom ones. And here starts the issues. As AutoIT help says, icons from GuiListView came from a loaded GUIImageList, which, seeing past images I conclude that it's already preloaded with some sort of most used icons (something like an icon cache?). But If I modify it (or create another GUIImageList and then put into the GuiListView) the icons became corrupted and replaced with blank ones. (can be reverted deleting IconCache.db, just like when windows shows wrong icons in desktop).
      How I change icons? Here
      $hImage = _GUIImageList_Create(48, 48, 5) ; create an image list for 48x48 icons $newIcon = _GUIImageList_AddIcon($imageList, @SystemDir & "\shell32.dll", 110) ; just adding a new icon in the image list _GUICtrlListView_SetImageList($hWnd, $hImage, 0) ; $hwnd is the desktop hwnd Another option as workaround for setting icons was getting the desktop GUIImageList, and modifiyng it directly. I otbtain a GUIImageList handle, but ... without any images inside! (That's strange beacuse, when I set desktop item icons without altering the GUIImageList, it applies correctly). And finally if I try to add new ones, it returns -1 with @error setted.
      How I'm trying to get  desktop GUIImageList? Here.
      $imageList = _GUICtrlListView_GetImageList ( $hWnd, 0 ) MsgBox(0,_GUIImageList_GetImageCount ( $imageList ), $imageList) ; getting image count and GUIImageList handle $newIcon = _GUIImageList_AddIcon($imageList, @SystemDir & "\shell32.dll", 110) ; adding icons without success So, what is the question? There's something wrong I'm doing while trying to set the new icon set on desktop? Or desktop icons work in different way than the rest of the GuiListView's? Or there's something really stupid that I can't saw before that corrupts the icons? 
      Also... if there's not known solution for that, do you have some idea for doing a workaround for that? Or another crazy idea? (Maybe putting real files instead dummy icons could be a solution ... a very slow one). Or even maybe (maybe not, I sure about that xD) do you want to help with this "experiment".
      Thanks in advance, have a good day