AwAke Posted September 5, 2008 Share Posted September 5, 2008 (edited) After hitting the File Size button and the second GUI being created, when hitting the X or hitting close closes the whole program, is there a way to stop this? P.S Sorry for the messy code, im quite new to programming. hehe =] expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #Include <File.au3> #Include <Array.au3> Global $gui = GUICreate("test", 370, 130, 500, 500, -1) GUISetState(@SW_SHOW) $Filesize = GUICtrlCreateButton("File Size", 313, 10) While 1 $msg = GUIGetMsg() Select Case $msg = $Filesize _fileSize() Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Wend Func _fileSize() GUISetState(@SW_DISABLE, $gui) Local $button, $item1, $item2, $item3, $input1, $msg Local $listview Local $child = GUICreate("test", 220, 250, 100, 200, -1, -1, $gui) Local $listview = GUICtrlCreateListView("File Name | Size", 10, 10, 200, 200);,$LVS_SORTDESCENDING) Local $go = GuiCtrlCreateButton("Search", 50, 218) Local $close = GuiCtrlCreateButton("Close", 130, 218) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $go $search = FileFindFirstFile(@ProgramFilesDir & "\*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit EndIf Local $avArray[1] Local $asArray[1] Local $Array[1] While 1 $file = FileFindNextFile($search) $path = @ProgramFilesDir & "\" & $file If @error Then ExitLoop $size = DirGetSize($path) $size = Round($size/1024/1024) _ArrayAdd($asArray, $file) _ArrayAdd($avArray, $size) $item1 = GUICtrlCreateListViewItem($file &"|"&$size& "MB's", $listview) WEnd FileClose($search) Case $msg = $close Exit Case $msg = $GUI_EVENT_CLOSE Exit EndSelect Wend EndFunc ;==>Example Edited September 5, 2008 by AwAke Link to comment Share on other sites More sharing options...
DjDeep00 Posted September 5, 2008 Share Posted September 5, 2008 @Awake...Even messier then yours...lol expandcollapse popup#include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #Include <File.au3> #Include <Array.au3> Global $gui = GUICreate("test", 370, 130, 500, 500, -1) GUISetState(@SW_SHOW) $Filesize = GUICtrlCreateButton("File Size", 313, 10) While 1 $msg = GUIGetMsg() Select Case $msg = $Filesize _fileSize() GUISetState(@SW_ENABLE, $gui) GUISetState(@SW_RESTORE, $gui) Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Wend Func _fileSize() GUISetState(@SW_DISABLE, $gui) Local $button, $item1, $item2, $item3, $input1, $msg Local $listview Local $child = GUICreate("test", 220, 250, 100, 200, -1, -1, $gui) Local $listview = GUICtrlCreateListView("File Name | Size", 10, 10, 200, 200);,$LVS_SORTDESCENDING) Local $go = GuiCtrlCreateButton("Search", 50, 218) Local $close = GuiCtrlCreateButton("Close", 130, 218) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $go $search = FileFindFirstFile(@ProgramFilesDir & "\*.*") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") ExitLoop EndIf Local $avArray[1] Local $asArray[1] Local $Array[1] While 1 $file = FileFindNextFile($search) $path = @ProgramFilesDir & "\" & $file If @error Then ExitLoop $size = DirGetSize($path) $size = Round($size/1024/1024) _ArrayAdd($asArray, $file) _ArrayAdd($avArray, $size) $item1 = GUICtrlCreateListViewItem($file &"|"&$size& "MB's", $listview) WEnd FileClose($search) Case $msg = $close GUIDelete($child) ExitLoop Case $msg = $GUI_EVENT_CLOSE GUIDelete($child) ExitLoop EndSelect Wend EndFunc ;==>Example Link to comment Share on other sites More sharing options...
AwAke Posted September 5, 2008 Author Share Posted September 5, 2008 Haha thank you mate, the mess doesnt concern me as of right now and it looks pretty clean. Does the job. Really appreciate it mate, Thanks alot. 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