PHPWarner Posted December 24, 2009 Posted December 24, 2009 Hello friends, I need to little help for find a solution to my problem. I've 2 simple GUI, the first one is main GUI included about button and quit button. The second GUI is the about box, which contains product information and OK button which I want to close only about GUI and then return to the main GUI. Below is the sample codes: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Main", 192, 64, 192, 114) $About = GUICtrlCreateButton("About", 16, 16, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Quit", 96, 16, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $About $Form2 = GUICreate("About", 324, 241, 425, 149) GUISetIcon("D:\006.ico") $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185) $Image1 = GUICtrlCreatePic("", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, $WS_GROUP) $Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, $WS_GROUP) $Label4 = GUICtrlCreateLabel("Comments", 16, 160, 53, 17, $WS_GROUP) $Label3 = GUICtrlCreateLabel("Copyright", 16, 136, 48, 17, $WS_GROUP) GUICtrlCreateGroup("", -99, -99, 1, 1) $Close_Button = GUICtrlCreateButton("&OK", 112, 208, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Close_Button Exit ; this is closing app completely, I want to close only about GUI and then return to the main GUI EndSwitch WEnd EndSwitch WEnd So many thanks in advice.
Yashied Posted December 24, 2009 Posted December 24, 2009 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Close_Button GUIDelete($Form2) ExitLoop ; Exit EndSwitch WEnd My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
PlatinumHex Posted February 7, 2010 Posted February 7, 2010 I'm facing the same problems as well. I tried what Yashield suggested, but only worked once. First I run the script, when I click the "About" Button it worked fine. The About Box showed up. After that, I closed the "About" Box. Then, I tried clicking the "About" Button again. Yet! Nothing showed up! What's wrong?
kaotkbliss Posted February 7, 2010 Posted February 7, 2010 I believe it is because the GUI is deleted. It might be easier to set the gui for the "about" at GUISetState(@SW_HIDE, $Form2) when it is first created then when the button is clicked to bring up the gui use GUISetState(@SW_SHOW, $Form2) the close button would be a simple GUISetState(@SW_HIDE, $Form2) again. 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
GEOSoft Posted February 7, 2010 Posted February 7, 2010 Also take a look in the help file at GUISwitch() George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
Fire Posted February 12, 2010 Posted February 12, 2010 Hi to all. PHPWarner & PlatinumHex This works fine for me.expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <StaticConstants.au3> $Form1 = GUICreate("MAIN GUI", 265, 137) ;creating MAIN GUI $Button1 = GUICtrlCreateButton("About", 24, 72, 73, 25, $WS_GROUP) $nope = GUICtrlCreateButton("Exit", 168, 72, 73, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("This is a GUI 1`S LABEL", 72, 24, 120, 17) $hfilemenu=GUICtrlCreateMenu("File") $hfilemenu_fisrtitem=GUICtrlCreateMenuItem("About",$hfilemenu) GUICtrlCreateMenuItem("",$hfilemenu) $hfilemenu_itemEXIT=GUICtrlCreateMenuItem("Exit",$hfilemenu) GUICtrlCreateMenuItem("",$hfilemenu) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 _haqqda() Case $nope $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15) If $hanswer="1" Then Exit EndIf Case $hfilemenu_fisrtitem _haqqda() Case $hfilemenu_itemEXIT $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15) ; timeout= 15 sec If $hanswer="1" Then ; 1 <= mean OK. See the help file of Autoit for msgbox() You can find about it :) Exit EndIf EndSwitch WEnd Func _haqqda() GUIDelete($Form1) ;deleting $Form1 . This is a previous GUI . $Form2 = GUICreate("About", 324, 234) ;creating second GUI .In that case this is a <ABOUT> GUI. $Label1 = GUICtrlCreateLabel("Product Name", 152, 24, 72, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD)) $Label2 = GUICtrlCreateLabel("Version", 152, 48, 39, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD)) $Label4 = GUICtrlCreateLabel("Comments: ", 16, 160, 53, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD)) $Label3 = GUICtrlCreateLabel("sh3llc043r", 16, 136, 48, 17, BitOR($SS_NOTIFY,$WS_GROUP,$WS_VISIBLE,$WS_CHILD)) $Button2 = GUICtrlCreateButton("&OK", 112, 208, 75, 25, BitOR($WS_TABSTOP,$WS_VISIBLE,$WS_CHILD)) $Image1 = GUICtrlCreatePic(@SystemDir& "\oobe\html\mouse\images\pisa.jpg", 16, 24, 105, 97, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState() SoundPlay(@WindowsDir & "\media\tada.wav",0) ;play tada.wav when About GUI Appears :) WIN XP SP2 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form2) _aka() Case $Button2 GUIDelete($Form2) ;deleting <ABOUT> GUI _aka() ;creating 1`st GUI again. For func see below => Func _aka() EndSwitch WEnd EndFunc;<==>_haqqda() Func _aka() $Form1 = GUICreate("MAIN GUI", 265, 137) $Button1 = GUICtrlCreateButton("About", 24, 72, 73, 25, $WS_GROUP) $nope = GUICtrlCreateButton("Exit", 168, 72, 73, 25, $WS_GROUP) $Label1 = GUICtrlCreateLabel("This is a GUI 1`S LABEL", 72, 24, 120, 17) $hfilemenu=GUICtrlCreateMenu("File") $hfilemenu_fisrtitem=GUICtrlCreateMenuItem("About",$hfilemenu) GUICtrlCreateMenuItem("",$hfilemenu) $hfilemenu_itemEXIT=GUICtrlCreateMenuItem("Exit",$hfilemenu) GUICtrlCreateMenuItem("",$hfilemenu) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hfilemenu_fisrtitem _haqqda() Case $hfilemenu_itemEXIT ;confirm exit $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15) ; timeout=15 sec If $hanswer="1" Then ; 1 <= mean OK. See the help file of Autoit for msgbox() You can find about it :) Exit EndIf Case $Button1 _haqqda() Case $nope $hanswer=MsgBox(65,"Do You Want Exit?","Dou You Want Exit?",15) ; timeout=15 sec If $hanswer="1" Then ; 1 <= mean OK. See the help file of Autoit for msgbox() You can find about it :) Exit EndIf EndSwitch WEnd EndFunc; <===> _aka() [size="5"] [/size]
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