Jump to content

closing a popup gui


d0n
 Share

Recommended Posts

I have something like this, i want to be able to close just the popup window, not both.

I think i have to do some child/parent gui thing? not sure :S

#include <GUIConstantsEx.au3>
GUICreate("123", 300, 300)
$Button = GUICtrlCreateButton("Button", 10, 10, 200, 75)
GUISetState(@SW_SHOW)

$Popup = GUICreate("321", 300, 30)
GUICtrlCreateLabel("123", 8, 5, 250, 30)
GUISetState(@SW_HIDE)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Button Then GUISetState(@SW_SHOW, $Popup)
WEnd

I am trying to make a popup box that shows an edit field to copy out stuff and then it can be closed

I tried using Inputbox, it works but i just dont like the OK and Cancel button, I want only want 1 button or no button lol

Edited by d0n
Link to comment
Share on other sites

you double posted. Please don't do that

This will hide the popup window if it exsist regardless of witch exit button is pressed. pressing it while only the main window is showing will exit

#include <GUIConstantsEx.au3>
GUICreate("123", 300, 300)
$Button = GUICtrlCreateButton("Button", 10, 10, 200, 75)
GUISetState(@SW_SHOW)

$Popup = GUICreate("321", 300, 30)
GUICtrlCreateLabel("123", 8, 5, 250, 30)
GUISetState(@SW_HIDE)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        If WinGetState($popup) = 4 then 
            GUISetState(@SW_HIDE,$popup)
        else
            exitloop
        endif
    If $msg = $Button Then GUISetState(@SW_SHOW, $Popup)
WEnd

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Time for you to journey into OnEvent Mode land:

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)  ; Change to OnEvent mode 

$guiMain = GUICreate("123", 300, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI_EVENT_CLOSE") ; Tells the GUI to call this func when you hit the X
$Button = GUICtrlCreateButton("Button", 10, 10, 200, 75)
GUICtrlSetOnEvent (-1, "_ShowPopup")  ; Tells the GUI to call this func when you hit the button
GUISetState(@SW_SHOW)

$guiPopup = GUICreate("321", 300, 30)
GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI_EVENT_CLOSE") ; Tells the GUI to call this func when you hit the X
GUICtrlCreateLabel("123", 8, 5, 250, 30)

GUISwitch($guiMain)

While 1
    Sleep (100)
WEnd

Func _ShowPopup()
    GUISetState(@SW_SHOW, $guiPopup)
EndFunc

Func _GUI_EVENT_CLOSE() 
    If @GUI_WinHandle = $guiPopup Then
        GUISetState(@SW_HIDE, $guiPopup)
    Else
        Exit
    EndIf
EndFunc
Edited by exodius
Link to comment
Share on other sites

Example of using the advanced parameter:

#include <GUIConstantsEx.au3>
$Main = GUICreate("123", 300, 300)
$Button = GUICtrlCreateButton("Button", 10, 10, 200, 75)
GUISetState(@SW_SHOW)

$Popup = GUICreate("321", 300, 30)
GUICtrlCreateLabel("123", 8, 5, 250, 30)
GUISetState(@SW_HIDE)

While 1
    $msg = GUIGetMsg(1)
    If $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $Popup Then GUISetState(@SW_HIDE, $Popup)
    If $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $Main Then ExitLoop
    If $msg[0] = $Button Then GUISetState(@SW_SHOW, $Popup)
WEnd

Hi ;)

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...