Jump to content
Sign in to follow this  
Zomp

how to make a modal always on top gui windows

Recommended Posts

Zomp

Forgive me if I don't know the right words. I have a GUI window and a button on it which opens another GUI window. Such window has to lay over the window it has been call and it must prevent the user to focus previous windows of the same AutoIt script.

Which commands or flags have I to use to open such window?

Thanks.

Edited by Zomp

Share this post


Link to post
Share on other sites
Andreik

Forgive me if I don't know the right words. I have a GUI window and a button on it which opens another GUI window. Such window has to lay over the other window and it must prevent the user to focus previous windows of the same AutoIt script.

How can I do it?

Create a GUI with $WS_EX_TOPMOST style. ;)


When the words fail... music speaks

Share this post


Link to post
Share on other sites
Zomp

Create a GUI with $WS_EX_TOPMOST style. ;)

Well, I have tried, but I also want that the "back" window remains no selectable while the foreground window is open. Similarly to waht happens when I open a "save as" dialog: any temptative to select to the back window yields a beep.

Is it possible?

Share this post


Link to post
Share on other sites
Andreik

Try WinSetOnTop().


When the words fail... music speaks

Share this post


Link to post
Share on other sites
SmOke_N

You can pass the main GUI's handle to the next GUI to open as it's parent GUI, and place the main GUI's handle in the parent hwnd parameter of the new GUI.

Before doing this, you want to LOCK the parent with GUISetState() + @SW_LOCK and then unlock it when you are done with the child GUI with GUISetState() + @SW_UNLOCK.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Zomp

You can pass the main GUI's handle to the next GUI to open as it's parent GUI, and place the main GUI's handle in the parent hwnd parameter of the new GUI.

Before doing this, you want to LOCK the parent with GUISetState() + @SW_LOCK and then unlock it when you are done with the child GUI with GUISetState() + @SW_UNLOCK.

Sorry, I have tried but without success. In the following toy example, I can close the application even if the background window is locked. Am I doing anything wrong?

#include <GUIConstants.au3>


$back=Guicreate("")
$close=GUICtrlCreateButton("close",10,10)
$open=GUICtrlCreateButton("open",10,50)
guisetstate(@SW_SHOW)
$fore=Guicreate("","","","","","",$WS_EX_TOPMOST,$back)
guisetstate(@SW_HIDE)

While true
    $msg=GUIGetMsg()
    Switch $msg
        case $close
            Exit
        case $open
            guisetstate(GUISetState() + @SW_LOCK,$back)
            guisetstate(@sw_show,$fore)
    EndSwitch
WEnd

exit

Share this post


Link to post
Share on other sites
martin

Sorry, I have tried but without success. In the following toy example, I can close the application even if the background window is locked. Am I doing anything wrong?

#include <GUIConstants.au3>


$back=Guicreate("")
$close=GUICtrlCreateButton("close",10,10)
$open=GUICtrlCreateButton("open",10,50)
guisetstate(@SW_SHOW)
$fore=Guicreate("","","","","","",$WS_EX_TOPMOST,$back)
guisetstate(@SW_HIDE)

While true
    $msg=GUIGetMsg()
    Switch $msg
        case $close
            Exit
        case $open
            guisetstate(GUISetState() + @SW_LOCK,$back)
            guisetstate(@sw_show,$fore)
    EndSwitch
WEnd

exit
You need

case $open
            guisetstate(@SW_DISABLE,$back)
            guisetstate(@sw_show,$fore)

Then when you want to get back to the 'back' gui set @SW_ENABLE. I think @SW_LOCK just stops repainting.

You need some way to get back at the moment because in your example there is no way to close the script once the 'back' gui is disabled.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Zomp

You need

case $open
            guisetstate(@SW_DISABLE,$back)
            guisetstate(@sw_show,$fore)

Then when you want to get back to the 'back' gui set @SW_ENABLE. I think @SW_LOCK just stops repainting.

You need some way to get back at the moment because in your example there is no way to close the script once the 'back' gui is disabled.

Perfect! Many thanks.

Share this post


Link to post
Share on other sites
DYONISII

hey guys!

could you help me a bit?

i need a modal fileopendialog so i have the following code:

GUISetState(@SW_DISABLE, $parent)
$retval = FileOpenDialog("Select File", "", "All (*.*)", 1)
GUISetState(@SW_ENABLE, $parent)

following is my dilemma:

after closing the fileopendialog window, either by selecting a file or by cancel, the main window loses focus. my option for the moment is "WinActivate" after i enable the parent window.

my other option is to use @SW_HIDE and @SW_SHOW, but the preference for the moment is not to hide the $parent window, but rather let it stand there.

thanks in advance for your help!

Edited by DYONISII

http://dev.dyonisii.com/

Share this post


Link to post
Share on other sites
DYONISII

found it!

the last parameter of fileopendialog is "hwnd." including it would make the dialog box modal. hehehe...


http://dev.dyonisii.com/

Share this post


Link to post
Share on other sites
babelpatcher

found it!

the last parameter of fileopendialog is "hwnd." including it would make the dialog box modal. hehehe...

can you or anyone tell me how to set the hwnd correctly?

i have same problem here :(

Share this post


Link to post
Share on other sites
Melba23

babelpatcher,

Stick with just one thread at a time please. ;)

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

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  

×