Sign in to follow this  
Followers 0
darkshadow791

Multiple (2) GUI's with OnEvent mode?

7 posts in this topic

#1 ·  Posted (edited)

Is it possible (and if so, how) to be able to have a (main) GUI running under onevent mode and another gui that can be created and deleted based on the user still accept input? I've tried using onevent for the second gui so it doesn't work. So I tried toggling the option for onevent mode back and forth, but that doesn't seem to work either.

Func ManageDef()
    $Manage = GuiCreate("Note Definition Manager", 500, 450,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
    GUISetState()
    $List[0][0] = GUICtrlCreateListView("Abbreviation|Word", 10, 40, 240, 344)
    Opt("GUIOnEventMode",0)
;;;GUICtrlSetOnEvent(-1,"ListSelected")
    For $count = 1 To _FileCountLines("Definitions.txt") Step 1
        $temp = StringSplit(FileReadLine("Definitions.txt",$count),"|")
        $List[$count][0] = GUICtrlCreateListViewItem($temp[1] & "|" & $temp[2],$List[0][0])
    Next
    
    $Lab_Title = GuiCtrlCreateLabel("Note Definition Manager v1.0", 10, 10, 240, 20)
    $Lab_Abbrev = GuiCtrlCreateLabel("Note", 270, 40, 210, 20)
    $In_Abbrev = GuiCtrlCreateInput("", 270, 80, 210, 30)
    $Lab_ChangeTo = GuiCtrlCreateLabel("Change To...", 270, 150, 210, 20)
    $In_ChangeTo = GuiCtrlCreateInput("", 270, 180, 210, 30)
    $Lab_Status = GuiCtrlCreateLabel("Status", 270, 250, 210, 40)
;
    $But_Cancel = GuiCtrlCreateButton("Cancel", 270, 320, 100, 50)
;;;GUICtrlSetOnEvent(-1,"CancelItem")
    $But_Save = GuiCtrlCreateButton("Save", 380, 320, 100, 50)
;;;GUICtrlSetOnEvent(-1,"ManSave")
    $But_Finish = GuiCtrlCreateButton("Finish", 270, 380, 210, 50)
;;;GUICtrlSetOnEvent(-1,"CloseDef")
    $But_Delete = GuiCtrlCreateButton("Delete Item", 10, 400, 110, 30)
;;;GUICtrlSetOnEvent(-1,"DeleteItem")
    $But_Add = GuiCtrlCreateButton("Add Item", 140, 400, 110, 30)
;;;GUICtrlSetOnEvent(-1,"AddItem")  
    
    GUISetOnEvent($GUI_EVENT_CLOSE,"CloseDef")
    
    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $List[0][0]
                ListSelected()
            Case $But_Cancel
                CancelItem()
            Case $But_Save
                ManSave()
            Case $But_Finish
                CloseDef()
            Case $But_Delete
                DeleteItem()
            Case $But_Add
                AddItem()
        EndSwitch
    WEnd
    
EndFunc
This is inside another GUI that is always running (if GUI isn't running then the program won't either.) I can't seem to figure out a way to be able to recieve msg's (Either GuiGetMsg or guictrlsetonevent msg's) for both gui's interchangeably...

If needed I can post more code.

Edited by darkshadow791

Share this post


Link to post
Share on other sites



Is it possible (and if so, how) to be able to have a (main) GUI running under onevent mode and another gui that can be created and deleted based on the user still accept input? I've tried using onevent for the second gui so it doesn't work. So I tried toggling the option for onevent mode back and forth, but that doesn't seem to work either.

This is inside another GUI that is always running (if GUI isn't running then the program won't either.) I can't seem to figure out a way to be able to recieve msg's (Either GuiGetMsg or guictrlsetonevent msg's) for both gui's interchangeably...

If needed I can post more code.

#include <guiconstants.au3>

Opt("GuiOnEventMode", 1)
$hGuiParent = GUICreate("Parent GUI", 200, 100, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUISetState()

$hGuiChild = GUICreate("Child GUI", 200, 100, 300, 300, -1, -1, $hGuiParent)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Warn")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func _Warn()
    MsgBox(16, "Warning", "You are closing the window.")
    GUIDelete($hGuiChild)
EndFunc

That's an example of Child GUI, you should use that instead.

Share this post


Link to post
Share on other sites

I tried doing this but for some reason it conflicted with my original gui's GuiCtrlCreateEdit field...

Also, my main GUI is controlled via OnEvent functions. I can't manage to have the second gui be controlled by onevent functions, but I can switch onevent mode off and then use the standard switch guigetmsg() while loop. However, after doing this my original gui fails to work, even after re-enabling onevent mode.

If needed I can upload my code.

Share this post


Link to post
Share on other sites

I tried doing this but for some reason it conflicted with my original gui's GuiCtrlCreateEdit field...

Also, my main GUI is controlled via OnEvent functions. I can't manage to have the second gui be controlled by onevent functions, but I can switch onevent mode off and then use the standard switch guigetmsg() while loop. However, after doing this my original gui fails to work, even after re-enabling onevent mode.

If needed I can upload my code.

For me I have a main GUI and a child GUI, I use a func to create GUI just like yours, and on event works perfectly fine.

Please upload your code so I can see what's the problem and test it.

Share this post


Link to post
Share on other sites

For me I have a main GUI and a child GUI, I use a func to create GUI just like yours, and on event works perfectly fine.

Please upload your code so I can see what's the problem and test it.

I can't find an option to upload it so here is a dl link:

http://vacdisabled.net/darkshadow/Gui%20Error.rar

Open "base.au3" and compile.

The second gui is created via Tools > Notes > Manage Notes

As of now it doesn't seem to work.

You can look at both the gui and the new gui in "Gui.au3" and "Funcs\Tools.au3" respectively. If you have any questions please let me know. I appreciate your help :shocked:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I can't find an option to upload it so here is a dl link:

http://vacdisabled.net/darkshadow/Gui%20Error.rar

Open "base.au3" and compile.

The second gui is created via Tools > Notes > Manage Notes

As of now it doesn't seem to work.

You can look at both the gui and the new gui in "Gui.au3" and "Funcs\Tools.au3" respectively. If you have any questions please let me know. I appreciate your help :shocked:

Few things to fix, base.au3 is the script you going to compile, so you only need to state
Opt("GUIOnEventMode",1)
once. In tool.au3, the func Managedef is the 1 that creates the GUI, remove the While Loop statement in it because you already have it in your base.au3 which is the main GUI.

See if that works.

Tested it worked. Just fill out rest of the func.

Edited by Generator

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