Dana Posted December 18, 2009 Share Posted December 18, 2009 (edited) I must be missing something really obvious. I'm trying to create a window with a child window, but when I do, neither the main window nor the child get displayed. I've stripped out all the nonessential code from this example:expandcollapse popup$version = "0.1" Opt("TrayIconDebug", 1) #include <GUIConstantsEx.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> #include <EditConstants.au3> #include <File.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <WinAPI.au3> $w = 1024 $h = 700 Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Logbook v" & $version & "main window", $w, $h,-1,-1, $WS_OVERLAPPEDWINDOW) $datawindow = GUICreate("Logbook v" & $version, $w-100, $h-100,-1,-1, $WS_CHILD,-1, $mainwindow) GUICtrlCreateLabel("Test label", 30, 10) $printbutton = GUICtrlCreateButton("Print", 30, $h - 40, 60) $closebutton = GUICtrlCreateButton("Close", $w - 30 - 60, $h - 40, 60) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked") GUICtrlSetOnEvent($closebutton, "CloseClicked") GUICtrlSetOnEvent($printbutton, "PrintClicked") GUISetState(@SW_SHOW) While 1 ;do stuff here Sleep(250) ; keep the GUI from eating up all the CPU cycles WEnd Func CloseClicked() GUIDelete() ;FileClose($file) ;If ($dataline == 0) Then FileDelete($logfile) ; don't save empty file Exit EndFunc ;==>CloseClicked Func PrintClicked() Exit EndFunc ;==>PrintClicked Opt("GUIOnEventMode", 0) ; Disable OnEvent modeIf I comment out the line (18) where I'm trying to create the child window, there are no problems and the script loops on the sleep line until I close the window, as expected. With the line in, nothing at all gets displayed on the screen and the script loops on the sleep line. However, if I click on the autoit icon in the taskbar and attempt to exit the script, my computer locks up and I have to power it down; I can't even get to task manager at that point. If I don't try to exit it from the icon, task manager can kill it.What am I missing?-Dana Edited December 18, 2009 by Dana Link to comment Share on other sites More sharing options...
smashly Posted December 18, 2009 Share Posted December 18, 2009 (edited) Hi Missing a GUISetState(@SW_SHOW) after creating the main window. Also in on event with multi gui you might be better off using the handle variable for the events, can save any confusion on window/control the event belongs to.. eg: GUISetState(@SW_SHOW, $mainwindow) and GUISetState(@SW_SHOW, $datawindow) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked", $mainwindow) etc.. Cheers Edited December 18, 2009 by smashly Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2009 Moderators Share Posted December 18, 2009 Dana,You need to GUISetState the main window before trying to cretae the child: expandcollapse popup$version = "0.1" Opt("TrayIconDebug", 1) #include <GUIConstantsEx.au3> #include <ListviewConstants.au3> #include <GuiListView.au3> #include <EditConstants.au3> #include <File.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Include <WinAPI.au3> $w = 1024 $h = 700 Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Logbook v" & $version & "main window", $w, $h,-1,-1, $WS_OVERLAPPEDWINDOW) GUICtrlCreateLabel("Test label", 30, 10) $printbutton = GUICtrlCreateButton("Print", 30, $h - 40, 60) $closebutton = GUICtrlCreateButton("Close", $w - 30 - 60, $h - 40, 60) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked") GUICtrlSetOnEvent($closebutton, "CloseClicked") GUICtrlSetOnEvent($printbutton, "PrintClicked") GUISetState(@SW_SHOW) $datawindow = GUICreate("Logbook v" & $version, $w-100, $h-100,-1,-1, $WS_CHILD,-1, $mainwindow) GUISetBkColor(0xFFFF00, $datawindow) GUISetState(@SW_SHOW) While 1 ;do stuff here Sleep(250) ; keep the GUI from eating up all the CPU cycles WEnd Func CloseClicked() GUIDelete() ;FileClose($file) ;If ($dataline == 0) Then FileDelete($logfile) ; don't save empty file Exit EndFunc ;==>CloseClicked Func PrintClicked() Exit EndFunc ;==>PrintClickedM23 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...
Dana Posted December 18, 2009 Author Share Posted December 18, 2009 Thanks, M23, that did the trick. I thought I had tried that but apparently not, though I never tried changing the color to see what was happening, too. The only part I don't understand now is why the position of the child window is unpredictable when I use the default -1 for the locations... I thought it should be centerned? Not a biggie, as I can get it to where I want by explicitly locating it. -Dana Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 18, 2009 Moderators Share Posted December 18, 2009 Dana,Sorry, never thought of that!As far as I know a child window needs to be located relative to the parent - otherwise why are you creating it?. I have never tried to locate at the -1, -1 position. I will have play (perhaps ) and see what is going on.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...
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