BlackHoleSun Posted September 19, 2010 Share Posted September 19, 2010 I have an about window and while the program loads you can see it flash while it goes through the code before getting to GUISetState(@SW_HIDE). My question is, how to I keep the window hidden from the beginning? Some of the code is below: $aboutWindow = GUICreate("About", 200, 225) $aboutClose = GUICtrlCreateButton("&OK", 75, 200, 50, 20) GUISetState(@SW_HIDE) Link to comment Share on other sites More sharing options...
BlackHoleSun Posted September 19, 2010 Author Share Posted September 19, 2010 (edited) I threw it into it's own function, and that works. Edited September 19, 2010 by BlackHoleSun Link to comment Share on other sites More sharing options...
BlackHoleSun Posted September 19, 2010 Author Share Posted September 19, 2010 Now that it has it's own function, when I close the window I can't close the main window without using the Task Manager. Link to comment Share on other sites More sharing options...
Kalin Posted September 19, 2010 Share Posted September 19, 2010 Give me detail about your problem, post the full code? Link to comment Share on other sites More sharing options...
BlackHoleSun Posted September 19, 2010 Author Share Posted September 19, 2010 Here's the full code: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $msg ;Main Program Local $programWindow Local $fileMenu, $openMenu, $seperatorBar, $exitMenu Local $helpMenu, $aboutMenu $programWindow = GUICreate("My Program", 300, 300, (@DesktopWidth - 300) / 2, (@DesktopHeight - 300) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $fileMenu = GUICtrlCreateMenu("&File") $openMenu = GUICtrlCreateMenuItem("Open &Notepad", $fileMenu) $seperatorBar = GUICtrlCreateMenuItem("", $fileMenu) $exitMenu = GUICtrlCreateMenuItem("E&xit", $fileMenu) $helpMenu = GUICtrlCreateMenu("&Help") $aboutMenu = GUICtrlCreateMenuItem("&About", $helpmenu) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $exitMenu GUISwitch($aboutWindow) GUIDelete() GUISwitch($programWindow) GUIDelete() Exit Case $msg[0] = $openMenu Run("notepad.exe") ProcessWaitClose("notepad.exe") MsgBox(0, "Notepad", "The notepad should be closed") Case $msg[0] = $aboutMenu _About() EndSelect WEnd GUISetState() GUIDelete() Exit EndFunc ;==>_Main Func _About() ;About Window Local $aboutWindow, $msg Local $aboutLabel, $aboutClose $aboutWindow = GUICreate("About", 200, 225, (@DesktopWidth - 200) / 2, (@DesktopHeight - 225) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $aboutLabel = GUICtrlCreateLabel("Version", 0, 0, 200, 17) GUICtrlCreateLabel("Developed by Me", 0, 102, 200, 17) GUICtrlSetBkColor($aboutLabel, 0xffffff) $aboutClose = GUICtrlCreateButton("&OK", 75, 200, 50, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $aboutClose GUISetState(@SW_HIDE) EndSelect WEnd Exit EndFunc ;==>_About Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 19, 2010 Moderators Share Posted September 19, 2010 BlackHoleSun,You were not returning from the _About() function. I have made a few more changes - take a look: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) _Main() Func _Main() Local $msg ;Main Program Local $programWindow Local $fileMenu, $openMenu, $seperatorBar, $exitMenu Local $helpMenu, $aboutMenu $programWindow = GUICreate("My Program", 300, 300, (@DesktopWidth - 300) / 2, (@DesktopHeight - 300) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $fileMenu = GUICtrlCreateMenu("&File") $openMenu = GUICtrlCreateMenuItem("Open &Notepad", $fileMenu) GUICtrlCreateMenuItem("", $fileMenu) $exitMenu = GUICtrlCreateMenuItem("E&xit", $fileMenu) $helpMenu = GUICtrlCreateMenu("&Help") $aboutMenu = GUICtrlCreateMenuItem("&About", $helpMenu) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() ; No need for the advanced parameter Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $exitMenu Exit ; <<<<<<<<<<<<<<<< No need to delete the GUIs (and certainly not GUISwitch to them) - just exit! Case $msg = $openMenu Run("notepad.exe") ProcessWaitClose("notepad.exe") MsgBox(0, "Notepad", "The notepad should be closed") Case $msg = $aboutMenu _About() EndSelect WEnd EndFunc ;==>_Main Func _About() ;About Window Local $aboutWindow, $msg Local $aboutLabel, $aboutClose Local $aboutWindow = GUICreate("About", 200, 225, (@DesktopWidth - 200) / 2, (@DesktopHeight - 225) / 2, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $aboutLabel = GUICtrlCreateLabel("Version", 0, 0, 200, 17) GUICtrlCreateLabel("Developed by Me", 0, 102, 200, 17) GUICtrlSetBkColor($aboutLabel, 0xffffff) $aboutClose = GUICtrlCreateButton("&OK", 75, 200, 50, 20) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $aboutClose GUIDelete($aboutWindow) ; <<<<<<<<<<<<<<<<<<<< Delete it or you waste resources by keeping the old one each time Return ; <<<<<<<<<<<<<<<<< You need to return the main function EndSelect WEnd Exit EndFunc ;==>_AboutYou might find the Managing Multiple GUIs tutorial in the Wiki of interest - it shows how you do use the "advanced" parameter with GUIGetMsg. Please ask if you have any questions. M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
BrewManNH Posted September 19, 2010 Share Posted September 19, 2010 Case $msg[0] = $GUI_EVENT_CLOSE Or $msg[0] = $exitMenu ; GUISwitch($aboutWindow) <<<<<<<<<<<< you don't need these lines, when you close the ; GUIDelete() <<<<<<<<<<<< main window, it closes both at the same time GUISwitch($programWindow) GUIDelete() Exit See the changes to your window close code above. 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 GudeHow 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 Link to comment Share on other sites More sharing options...
ALTIN Posted September 19, 2010 Share Posted September 19, 2010 BlackHoleSun, I have created this a while ago for another program of mine and it looks like it is exactly what you want... Try this: expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiButton.au3> #include <WindowsConstants.au3> #NoTrayIcon Opt("TrayMenuMode", 1) Opt('MustDeclareVars', 0) Opt("GUICloseOnESC", 1) ;1=ESC closes window when ESC is pressed ;main window global variables Global $msgMain, $mainWindow, $mainWidth = 460, $mainHeight = 350 ;main window width & height Local $fileMenu, $openMenu, $seperatorBar, $exitMenu Local $helpMenu, $aboutMenu Global $childOpen ;Group Pro Version ;child window global positioning variables Global $childWidth = 300 ;reg window width Global $childHeight = 150 ;reg window height Global $childLeft = ($mainWidth - $childWidth)/2 ;child left position from main window Global $childTop = ($mainHeight - $childHeight)/2 ;child top position from main window MainGui() Func MainGui() $mainWindow = GUICreate("Main Window", $mainWidth, $mainHeight) ; will create a dialog box that when displayed is centered GUISetBkColor(0xE0FFFF) ; will change background color $fileMenu = GUICtrlCreateMenu("&File") $openMenu = GUICtrlCreateMenuItem("Open &Notepad", $fileMenu) GUICtrlCreateMenuItem("", $fileMenu) $exitMenu = GUICtrlCreateMenuItem("E&xit", $fileMenu) $helpMenu = GUICtrlCreateMenu("&Help") $aboutMenu = GUICtrlCreateMenuItem("&About", $helpMenu) GUISetState(@SW_SHOW) ; Run the GUI until the window is closed While 1 $msgMain = GUIGetMsg() Select Case $msgMain = $GUI_EVENT_CLOSE ExitLoop Case $msgMain = $aboutMenu About_Window() EndSelect WEnd GUIDelete() Exit EndFunc ;==>MainGui Func About_Window() Local $pos = WinGetPos("Main Window") ;get position of main window Local $x = $pos[0] + $childLeft ;set child x position Local $y = $pos[1] + $childTop ;set child y position Global $childWindow = GUICreate("Child Window", $childWidth, $childHeight, $x, $y, $GUI_SS_DEFAULT_GUI, $WS_EX_TOOLWINDOW, $mainWindow) GUISetBkColor(0xE0FFbb) ; will change background color $aboutLabel = GUICtrlCreateLabel("Version", 0, 0, 200, 17) GUICtrlCreateLabel("Developed by Me", 0, 50, 200, 17) GUICtrlSetBkColor($aboutLabel, 0xffffff) Global $cmdCancel = GUICtrlCreateButton("&Cancel" , 125, 115, 80, 25) GUISetState(@SW_DISABLE, $childWindow) GUISetState(@SW_SHOW, $childWindow) _GUICtrlButton_Enable($cmdCancel, True) GUISetState(@SW_ENABLE, $childWindow) While 1 $msgChild = GuiGetMsg($childWindow) Select Case $msgChild = $GUI_EVENT_CLOSE GUISetState(@SW_HIDE, $childWindow) ExitLoop Case $msgChild = $cmdCancel GUISetState(@SW_HIDE, $childWindow) ExitLoop EndSelect WEnd EndFunc ;==>Child window Link to comment Share on other sites More sharing options...
BlackHoleSun Posted September 20, 2010 Author Share Posted September 20, 2010 BlackHoleSun,You were not returning from the _About() function. I have made a few more changes - take a look: You might find the Managing Multiple GUIs tutorial in the Wiki of interest - it shows how you do use the "advanced" parameter with GUIGetMsg. Please ask if you have any questions. M23The return did it, and I cleaned up some of the other code. Thanks!! 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