Jump to content

how to make a modal always on top gui windows


Zomp
 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

  • 3 months later...

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/

Link to comment
Share on other sites

  • 3 years later...
  • Moderators

babelpatcher,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...