Jump to content

Problem with Child GUI, It will not exit out without taking the parent with it.


Glyph
 Share

Recommended Posts

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=default.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=Untitled
#AutoIt3Wrapper_Res_Description=Untitled
#AutoIt3Wrapper_Res_Fileversion=3.19.0.0
#AutoIt3Wrapper_Res_LegalCopyright=???
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1033
://////=__=
://////=__=???
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
If UBound(ProcessList(@ScriptName)) > 2 Then
    MsgBox(64, "Untitled", "Already running!", 5)
    Exit
EndIf

#include <guiConstants.au3>
#include <windowsConstants.au3>
#include <GuiEdit.au3>
#include <misc.au3>

Opt("WinTitleMatchMode", 3)
Opt("TrayMenuMode", 1)

$appname = "Untitled"
$terminalwin = $appname & " Terminal"
$team = "BHI"
$terminalsocket = ""
$ver = "v4.0"
$aboutitem = TrayCreateItem("Show")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TraySetState()

$named = $appname & " " & $ver & " | " & $team
$guiw = "566" + 20
$guih = "194" + 20

$Gui = GUICreate($named, $guiw, $guih, @DesktopWidth / 10, @DesktopHeight / 3, $WS_OVERLAPPEDWINDOW)
$button = GUICtrlCreateButton("test", 0, 0, 50, 25)
GUISetState(@SW_SHOW, $Gui)

$gui2 = GUICreate($terminalwin, 400, 200, @DesktopWidth / 10, @DesktopHeight / 3, -1, -1, $Gui)

$terminaledit = GUICtrlCreateEdit($appname & " Terminal v0.3" & @CRLF & "======" & @CRLF, 10, 29, 380, 140, BitOR($ES_READONLY, $ES_AUTOVSCROLL, $ES_MULTILINE, $WS_VSCROLL))
GUICtrlSetBkColor($terminaledit, "0x000000")
GUICtrlSetColor($terminaledit, "0x00ff00")
$terminalcmd = GUICtrlCreateInput("", 10, 170, 380, 19)
GUICtrlSetBkColor($terminalcmd, "0x000000")
GUICtrlSetColor($terminalcmd, "0xffffff")

GUISetState(@SW_HIDE, $gui2)

_ReduceMemory()
While 1
    Sleep(1)
    If @SEC = "01" Then _ReduceMemory()
    $msg2 = TrayGetMsg()
    $msg = GUIGetMsg($Gui)
    $childmsg = GUIGetMsg($gui2)
    guicom()

WEnd

Func guicom()
    ;parent - $gui
    ;child - $gui2
    If $msg = $button Then
        GUISetState(@SW_SHOW, $gui2)
        MsgBox(0, "done", "done")
    EndIf
    
    If $childmsg = $gui_event_close Then
        GUISetState(@SW_HIDE, $gui2)
    EndIf
    
    If $msg = $GUI_EVENT_minimize Then GUISetState(@SW_HIDE, $Gui)
    
    If $msg = $gui_event_close Or $msg2 = $exititem Then
        $verify = MsgBox(4, $appname & " " & $ver, "Are you sure you want to exit?")
        If $verify = 6 Then
            Exit
        Else
            ;nothin
        EndIf
    EndIf

    If _IsPressed("0D", "user32.dll") And WinActive($terminalwin, "") = 1 And GUICtrlRead($terminalcmd) <> "" Then
        _GUICtrlEdit_AppendText($terminaledit, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] Sent: " & GUICtrlRead($terminalcmd) & @CRLF)
        GUICtrlSetData($terminalcmd, "")
    EndIf
EndFunc   ;==>guicom

Func _ReduceMemory()
    Sleep(1000)
    If FileExists(@SystemDir & "\psapi.dll") Then DllCall(@SystemDir & "\psapi.dll", "int", "EmptyWorkingSet", "long", -1)
EndFunc   ;==>_ReduceMemory

Exiting the Child triggers the parent exit event, I'm totally confused by this.

My logic, or something... is obviously flawed right now.

The child is supposed to minimize when i exit the child out, makes sense right?

Unfortunately, my code doesn't want to agree.

It would rather exit the parent out, when I exit the child!

Edited by Glyph

tolle indicium

Link to comment
Share on other sites

I'm trying to avoid the guigetmsg(1) command.

I made a workaroudn for the time being, setting a variable so it knows which gui is active, then minimizing the child if it is open. $childguiopen=1

If anyone knows the proper way for doing this without the guigetmsg(1), let me know!

and thank you for your help rasim, I appreciate the reply.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=default.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=Untitled
#AutoIt3Wrapper_Res_Description=Untitled
#AutoIt3Wrapper_Res_Fileversion=4.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=???
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1033
://////=__=
://////=__=???
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
If UBound(ProcessList(@ScriptName)) > 2 Then
    MsgBox(64, "Untitled", "Already running!", 5)
    Exit
EndIf

#include <guiConstants.au3>
#include <windowsConstants.au3>
#include <GuiEdit.au3>
#include <misc.au3>

Opt("WinTitleMatchMode", 3)
Opt("TrayMenuMode", 1)

$appname = "Untitled"
$terminalwin = $appname & " Terminal"
$team = "BHI"
$terminalsocket = ""
$ver = "v4.0"
$aboutitem = TrayCreateItem("Show")
TrayCreateItem("")
$exititem = TrayCreateItem("Exit")
TraySetState()

$named = $appname & " " & $ver & " | " & $team
$guiw = "566" + 20
$guih = "194" + 20

$Gui = GUICreate($named, $guiw, $guih, @DesktopWidth / 10, @DesktopHeight / 3, $WS_OVERLAPPEDWINDOW)
$button = GUICtrlCreateButton("test", 0, 0, 50, 25)
GUISetState(@SW_SHOW, $Gui)

$gui2 = GUICreate($terminalwin, 400, 200, @DesktopWidth / 10, @DesktopHeight / 3, -1, -1, $Gui)

$terminaledit = GUICtrlCreateEdit($appname & " Terminal v0.3" & @CRLF & "======" & @CRLF, 10, 29, 380, 140, BitOR($ES_READONLY, $ES_AUTOVSCROLL, $ES_MULTILINE, $WS_VSCROLL))
GUICtrlSetBkColor($terminaledit, "0x000000")
GUICtrlSetColor($terminaledit, "0x00ff00")
$terminalcmd = GUICtrlCreateInput("", 10, 170, 380, 19)
GUICtrlSetBkColor($terminalcmd, "0x000000")
GUICtrlSetColor($terminalcmd, "0xffffff")

GUISetState(@SW_HIDE, $gui2)

_ReduceMemory()
While 1
    Sleep(1)
    If @SEC = "01" Then _ReduceMemory()
    $msg2 = TrayGetMsg()
    $msg = GUIGetMsg($Gui)
    $childmsg = GUIGetMsg($gui2)
    ;parent - $gui
    ;child - $gui2
    If $msg = $button Then
        GUISetState(@SW_SHOW, $gui2)
        $childopen=1
    EndIf
    
    If $childmsg = $gui_event_close Then
        GUISetState(@SW_HIDE, $gui2)
        $childopen=0
    EndIf
    
    If $msg = $GUI_EVENT_minimize Then GUISetState(@SW_HIDE, $Gui)
    
    If $msg = $gui_event_close Or $msg2 = $exititem Then
        if $childopen=0 then
        $verify = MsgBox(4, $appname & " " & $ver, "Are you sure you want to exit?")
        If $verify = 6 Then
            Exit
        Else
            ;nothin
        EndIf
    Else
                GUISetState(@SW_HIDE, $gui2)
        $childopen=0
        EndIf
    EndIf

    If _IsPressed("0D", "user32.dll") And WinActive($terminalwin, "") = 1 And GUICtrlRead($terminalcmd) <> "" Then
        _GUICtrlEdit_AppendText($terminaledit, "[" & @HOUR & ":" & @MIN & ":" & @SEC & "] Sent: " & GUICtrlRead($terminalcmd) & @CRLF)
        GUICtrlSetData($terminalcmd, "")
    EndIf

WEnd



Func _ReduceMemory()
    Sleep(1000)
    If FileExists(@SystemDir & "\psapi.dll") Then DllCall(@SystemDir & "\psapi.dll", "int", "EmptyWorkingSet", "long", -1)
EndFunc   ;==>_ReduceMemory
Edited by Glyph

tolle indicium

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