jeansaad Posted March 1, 2005 Share Posted March 1, 2005 Hey Guys... Trying to write a special INI Viewer and I can't get the GUICtrlDelete() function to work... Generally this is how the program works: User opens a file and then they view it and then close the file, the list view is then deleted and the buttons are enabled to open another file. The only problem is that i can't get the list view to be deleted with the function. Any help is appreciated and feel free to use this code if you like!!! expandcollapse popup#include <GuiConstants.au3> #NoTrayIcon ; ---------------------------------------------------------------------------- ; Create the GUI features ; ---------------------------------------------------------------------------- $WinTitle = 'IniViewer' $WinWidth = 600 $WinHeight = 440 ;GUI GUICreate($WinTitle, $WinWidth, $WinHeight) GuiSetIcon('icon.ico', 0) ;FILE MENU $FileMenu = GuiCtrlCreateMenu ("File") $FileItem = GuiCtrlCreateMenuitem ("Open...", $FileMenu) $CloseItem = GuiCtrlCreateMenuitem ("Close", $FileMenu) $Separator = GuiCtrlCreateMenuitem ("", $FileMenu) $ExitItem = GuiCtrlCreateMenuitem ("Exit", $FileMenu) GUICtrlSetState ($CloseItem, $GUI_DISABLE) ;LIST VIEW Dim $listView ; ---------------------------------------------------------------------------- ; Set the operations for program events ; ---------------------------------------------------------------------------- GuiSetState() While 1 $Event = GuiGetMsg() Select Case $Event = -3 Or $Event = -1 or $Event = $ExitItem ExitLoop Case $Event = $FileItem Dim $Filename = FileOpenDialog("Select File:", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "INI Configuration Settings (*.ini)", 1) If FileExists ($Filename) Then ; LIST VIEW Dim $SectionNames = IniReadSectionNames ($Filename) Dim $KeyNames = IniReadSection ($Filename, $SectionNames[1]) Dim $Headings = '' Dim $Rows = '' For $i = 1 To $KeyNames[0][0] If $i = 1 Then $Headings = $Headings & $KeyNames[$i][0] Else $Headings = $Headings & '|' & $KeyNames[$i][0] EndIf Next $listView = GuiCtrlCreateListView($Headings, 0, 0, 600, 440) For $i = 1 To $SectionNames[0] $KeyNames = IniReadSection ($Filename, $SectionNames[$i]) For $j = 1 To $KeyNames[0][0] If $j = 1 Then $Rows = $Rows & $KeyNames[$j][1] Else $Rows = $Rows & '|' & $KeyNames[$j][1] EndIf Next GuiCtrlCreateListViewItem($Rows, $listView) $Rows = '' Next GUICtrlSetState ($FileItem, $GUI_DISABLE) GUICtrlSetState ($CloseItem, $GUI_ENABLE) EndIf Case $Event = $CloseItem GUICtrlDelete ($listView) GUICtrlSetState ($listView, $GUI_HIDE) GUICtrlSetState ($FileItem, $GUI_ENABLE) EndSelect WEnd GUIDelete() ; ---------------------------------------------------------------------------- ; Exit the Program ; ---------------------------------------------------------------------------- Exit Link to comment Share on other sites More sharing options...
SumTingWong Posted March 1, 2005 Share Posted March 1, 2005 (edited) See Assign and Eval for my changes: expandcollapse popup#include <GuiConstants.au3> #NoTrayIcon ; ---------------------------------------------------------------------------- ; Create the GUI features ; ---------------------------------------------------------------------------- $WinTitle = 'IniViewer' $WinWidth = 600 $WinHeight = 440 ;GUI GUICreate($WinTitle, $WinWidth, $WinHeight) GuiSetIcon('icon.ico', 0) ;FILE MENU $FileMenu = GuiCtrlCreateMenu ("File") $FileItem = GuiCtrlCreateMenuitem ("Open...", $FileMenu) $CloseItem = GuiCtrlCreateMenuitem ("Close", $FileMenu) $Separator = GuiCtrlCreateMenuitem ("", $FileMenu) $ExitItem = GuiCtrlCreateMenuitem ("Exit", $FileMenu) GUICtrlSetState ($CloseItem, $GUI_DISABLE) ;LIST VIEW Dim $listView ; ---------------------------------------------------------------------------- ; Set the operations for program events ; ---------------------------------------------------------------------------- GuiSetState() While 1 $Event = GuiGetMsg() Select Case $Event = -3 Or $Event = -1 or $Event = $ExitItem ExitLoop Case $Event = $FileItem Dim $Filename = FileOpenDialog("Select File:", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "INI Configuration Settings (*.ini)", 1) If FileExists ($Filename) Then ; LIST VIEW Dim $SectionNames = IniReadSectionNames ($Filename) Dim $KeyNames = IniReadSection ($Filename, $SectionNames[1]) Dim $Headings = '' Dim $Rows = '' For $i = 1 To $KeyNames[0][0] If $i = 1 Then $Headings = $Headings & $KeyNames[$i][0] Else $Headings = $Headings & '|' & $KeyNames[$i][0] EndIf Next $listView = GuiCtrlCreateListView($Headings, 0, 0, 600, 440) For $i = 1 To $SectionNames[0] $KeyNames = IniReadSection ($Filename, $SectionNames[$i]) For $j = 1 To $KeyNames[0][0] If $j = 1 Then $Rows = $Rows & $KeyNames[$j][1] Else $Rows = $Rows & '|' & $KeyNames[$j][1] EndIf Next Assign ("lvItem" & $i, GuiCtrlCreateListViewItem ($Rows, $listView)) $Rows = '' Next GUICtrlSetState ($FileItem, $GUI_DISABLE) GUICtrlSetState ($CloseItem, $GUI_ENABLE) EndIf Case $Event = $CloseItem For $i = 1 To $SectionNames[0] GUICtrlDelete (Eval ("lvItem" & $i)) Next GUICtrlSetState ($listView, $GUI_HIDE) GUICtrlSetState ($FileItem, $GUI_ENABLE) EndSelect WEnd GUIDelete() ; ---------------------------------------------------------------------------- ; Exit the Program ; ---------------------------------------------------------------------------- Exit Edited March 1, 2005 by pacman Link to comment Share on other sites More sharing options...
jeansaad Posted March 1, 2005 Author Share Posted March 1, 2005 I think I understand what you are trying to do... You have to delete the list view items before deleting the list view in order for it to remove that GUI object... I'll try that when I get home and tell you if it works, then I'll repost the program for anyone that wants to use it. Thanks a lot for your reply though... Link to comment Share on other sites More sharing options...
CyberSlug Posted March 1, 2005 Share Posted March 1, 2005 As an alternative, you could GuiCtrlSetPos(...) the ListView so that is is off screen (or is resized to 1 pixel x 1 pixel) or something. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! 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