exodius Posted March 31, 2008 Share Posted March 31, 2008 (edited) Using the following script, if you click the "Add Entries" button to add items to the ListView control and then click on the .5, .6, .7, and .8 entries, it will execute each of the 4 case statements available in the While loop. Does anyone know why? I'm using the GuiCtrlCreateListView instead of the UDF version because the UDF version doesn't do resizing... So that's not going to be an option. expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiListView.au3> #include <WindowsConstants.au3> $WFFHDQIP = GUICreate("WFFHD QIP", 690, 300, -1, -1, $WS_SIZEBOX) $GuiRelHor = 504 $GuiRelVer = 0 $ResizeVar = $GUI_DockTop+$GUI_DOCKHEIGHT+$GUI_DOCKWIDTH+$GUI_DockRight $listview = GUICtrlCreateListView ("", 10, 10, 480, 200) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) _GUICtrlListView_AddColumn ($listview, "IP Address", 90) _GUICtrlListView_AddColumn ($listview, "Object Name", 134) _GUICtrlListView_AddColumn ($listview, "Object Class", 90) _GUICtrlListView_AddColumn ($listview, "Status", 59) _GUICtrlListView_AddColumn ($listview, "Domain", 88) GUICtrlCreateGroup ("Commands", $GuiRelHor, $GuiRelVer+156, 175, 91) GUICtrlSetResizing (-1, $ResizeVar) $Ping = GUICtrlCreateButton ("Ping", $GuiRelHor+23, $GuiRelVer+182, 50, 25) GUICtrlSetResizing (-1, $ResizeVar) $PingT = GUICtrlCreateButton ("Ping -t", $GuiRelHor+103, $GuiRelVer+182, 50, 25) GUICtrlSetResizing (-1, $ResizeVar) $Telnet = GUICtrlCreateButton ("Telnet", $GuiRelHor+23, $GuiRelVer+212, 50, 25) GUICtrlSetResizing (-1, $ResizeVar) $CShare = GUICtrlCreateButton ("Add Entries", $GuiRelHor+98, $GuiRelVer+212, 60, 25) GUICtrlSetResizing (-1, $ResizeVar) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Ping MsgBox (0, "Ping", "This is the ping case statement") Case $PingT MsgBox (0, "Ping -t", "This is the ping -t case statement") Case $Telnet MsgBox (0, "Telnet", "This is the Telnet case statement") Case $CShare For $x = 0 to 10 _GUICtrlListView_AddItem($listview, "10.0.0." & $x) Next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited March 31, 2008 by exodius Link to comment Share on other sites More sharing options...
martin Posted March 31, 2008 Share Posted March 31, 2008 (edited) Using the following script, if you click the "Add Entries" button to add items to the ListView control and then click on the .5, .6, .7, and .8 entries, it will execute each of the 4 case statements available in the While loop. Does anyone know why? I'm using the GuiCtrlCreateListView instead of the UDF version because the UDF version doesn't do resizing... So that's not going to be an option. expandcollapse popup#include <GUIConstantsEx.au3> #Include <GuiListView.au3> #include <WindowsConstants.au3> $WFFHDQIP = GUICreate("WFFHD QIP", 690, 300, -1, -1, $WS_SIZEBOX) $GuiRelHor = 504 $GuiRelVer = 0 $ResizeVar = $GUI_DockTop+$GUI_DOCKHEIGHT+$GUI_DOCKWIDTH+$GUI_DockRight $listview = GUICtrlCreateListView ("", 10, 10, 480, 200) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) _GUICtrlListView_AddColumn ($listview, "IP Address", 90) _GUICtrlListView_AddColumn ($listview, "Object Name", 134) _GUICtrlListView_AddColumn ($listview, "Object Class", 90) _GUICtrlListView_AddColumn ($listview, "Status", 59) _GUICtrlListView_AddColumn ($listview, "Domain", 88) GUICtrlCreateGroup ("Commands", $GuiRelHor, $GuiRelVer+156, 175, 91) GUICtrlSetResizing (-1, $ResizeVar) $Ping = GUICtrlCreateButton ("Ping", $GuiRelHor+23, $GuiRelVer+182, 50, 25) GUICtrlSetResizing (-1, $ResizeVar) $PingT = GUICtrlCreateButton ("Ping -t", $GuiRelHor+103, $GuiRelVer+182, 50, 25) GUICtrlSetResizing (-1, $ResizeVar) $Telnet = GUICtrlCreateButton ("Telnet", $GuiRelHor+23, $GuiRelVer+212, 50, 25) GUICtrlSetResizing (-1, $ResizeVar) $CShare = GUICtrlCreateButton ("Add Entries", $GuiRelHor+98, $GuiRelVer+212, 60, 25) GUICtrlSetResizing (-1, $ResizeVar) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Ping MsgBox (0, "Ping", "This is the ping case statement") Case $PingT MsgBox (0, "Ping -t", "This is the ping -t case statement") Case $Telnet MsgBox (0, "Telnet", "This is the Telnet case statement") Case $CShare For $x = 0 to 10 _GUICtrlListView_AddItem($listview, "10.0.0." & $x) Next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Strange to me. It appears that when you click the item with ID 5 GUIGetMsg() returns 5 which is the id of one of the controls you have created. If you create the Listview using $listview = _GUICtrlListView_Create ($WFFHDQIP,"", 10, 10, 480, 200) then this doesn't happen. Perhaps you should add items to the list view with GuiCtrlSetData if you're using the internal listview? Edited March 31, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
exodius Posted March 31, 2008 Author Share Posted March 31, 2008 Strange to me. It appears that when you click the item with ID 5 GUIGetMsg() returns 5 which is the id of one of the controls you have created. If you create the Listview using$listview = _GUICtrlListView_Create ($WFFHDQIP,"", 10, 10, 480, 200)then this doesn't happen.Perhaps you should add items to the list view with GuiCtrlSetData if you're using the internal listview?That works, it's really interesting how the UDFs require you to switch back to the default functionality to accomplish some things, but others they handle just fine... Oh well, cool beans, thanks martin! Link to comment Share on other sites More sharing options...
PsaltyDS Posted March 31, 2008 Share Posted March 31, 2008 That works, it's really interesting how the UDFs require you to switch back to the default functionality to accomplish some things, but others they handle just fine... Oh well, cool beans, thanks martin! It was just a plain old bug. I ran it as below to duplicate and see the cause. It fails in Prod 3.2.10.0, but works correctly in 3.2.11.3 Beta. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> $WFFHDQIP = GUICreate("WFFHD QIP", 690, 300, -1, -1, $WS_SIZEBOX) $GuiRelHor = 504 $GuiRelVer = 0 $ResizeVar = $GUI_DockTop + $GUI_DOCKHEIGHT + $GUI_DOCKWIDTH + $GUI_DockRight $listview = GUICtrlCreateListView("", 10, 10, 480, 200) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) _GUICtrlListView_AddColumn($listview, "IP Address", 90) _GUICtrlListView_AddColumn($listview, "Object Name", 134) _GUICtrlListView_AddColumn($listview, "Object Class", 90) _GUICtrlListView_AddColumn($listview, "Status", 59) _GUICtrlListView_AddColumn($listview, "Domain", 88) GUICtrlCreateGroup("Commands", $GuiRelHor, $GuiRelVer + 156, 175, 91) GUICtrlSetResizing(-1, $ResizeVar) $Ping = GUICtrlCreateButton("Ping", $GuiRelHor + 23, $GuiRelVer + 182, 50, 25) GUICtrlSetResizing(-1, $ResizeVar) $PingT = GUICtrlCreateButton("Ping -t", $GuiRelHor + 103, $GuiRelVer + 182, 50, 25) GUICtrlSetResizing(-1, $ResizeVar) $Telnet = GUICtrlCreateButton("Telnet", $GuiRelHor + 23, $GuiRelVer + 212, 50, 25) GUICtrlSetResizing(-1, $ResizeVar) $CShare = GUICtrlCreateButton("Add Entries", $GuiRelHor + 98, $GuiRelVer + 212, 60, 25) GUICtrlSetResizing(-1, $ResizeVar) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Ping MsgBox(0, "Ping", "$nMsg = " & $nMsg) Case $PingT MsgBox(0, "Ping -t", "$nMsg = " & $nMsg) Case $Telnet MsgBox(0, "Telnet", "$nMsg = " & $nMsg) Case $CShare For $x = 0 To 10 _GUICtrlListView_AddItem($listview, "10.0.0." & $x) Next Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
exodius Posted March 31, 2008 Author Share Posted March 31, 2008 Peculiar, now that you mention that PsaltyDS, if I tell SciTE to do a beta run then it does work okay, although my original script (this was a test scenario I threw together) should have been compiling with the beta... Oh well, good to know, thanks for the help! Link to comment Share on other sites More sharing options...
GaryFrost Posted March 31, 2008 Share Posted March 31, 2008 http://www.autoitscript.com/forum/index.php?showtopic=59685 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...
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