Sign in to follow this  
Followers 0
Syrin

Parent window automatically hiding

4 posts in this topic

In the course of making myself an AutoIt program, I've come across this phenomenon, and I have no idea why it happens. I'm trying to make an "options" window, with standard options window behaviour. However, when it closes, the main window immediately loses focus. The only remedy is using WinActivate($main), but sometimes there's a slight flicker, and I find it to be rather unseemly.

Why does this happen, and is there any prettier way of going about this?

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>

Global $main,$toolsmenu,$options

CreateMainGUI()
CreateOptionsGUI()

While 1
    Sleep(1000)
WEnd

Func CreateMainGUI()
    Opt("GUIOnEventMode",1)
    $main = GUICreate("Example Window",500,300,-1,-1,$WS_TILEDWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
    $toolsmenu = GUICtrlCreateMenu("Tools")
    GUICtrlCreateMenuItem("Options",$toolsmenu)
    GUICtrlSetOnEvent(-1,"OpenOptions")
    GUISetState(@SW_SHOW)
EndFunc
Func CreateOptionsGUI()
    $options = GUICreate("Options",250,200,-1,-1,BitOR($WS_CAPTION,$WS_SYSMENU),-1,$main)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CloseOptions")
EndFunc
Func OpenOptions()
    GUISetState(@SW_SHOW, $options)
    GUISetState(@SW_DISABLE, $main)
EndFunc
Func CloseOptions()
    GUISetState(@SW_HIDE, $options)
    GUISetState(@SW_ENABLE, $main)
    ;WinActivate($main); <---when this is commented out (like it is currently),
    ;the window loses focus once the options window closes.
EndFunc
Func Terminate()
    Exit 0
EndFunc

Share this post


Link to post
Share on other sites



Syrin,

Welcome to the AutoIt forums. :)

If you re-enable the main GUI before you close the child, the main GUI regains focus as you wish: :P

Func CloseOptions()
    GUISetState(@SW_ENABLE, $main)
    GUISetState(@SW_HIDE, $options)
EndFunc   ;==>CloseOptions

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Well, that solves it - but my curiosity remains. Why would something as seemingly innocuous as the order of these two operations which (I thought) ought to be independent have an effect like this?

Edited by Syrin

Share this post


Link to post
Share on other sites

Syrin,

Ask a Dev in the "Developer Chat" forum if you really want to know - I just know it works! :)

M23

P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. :)


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0