Sign in to follow this  
Followers 0
cerberus

Help with more than one GUI

3 posts in this topic

Alright, I've tried a few things and I am obviously missing something fundamental here but I don't know what so I'm hoping for help.

I'm making a program that will track mission progress (with objectives) and logos per character using sqllite to keep track everything in the back end for Tabula Rasa. Yes they have an in game tracker but the objective tracker just sucks :)

Opt("GUIOnEventMode", 1)


;Build GUI here
$main = Guicreate("Character Tracking", 800, 600)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
guisetstate(@sw_show)

$addz = GuiCtrlCreateButton("Add New Zone", 10, 140)
GuiSetonEvent(-1, "AddZone")

Func AddZone()
guicreate("Add Zone", 400,400)
guisetstate(@sw_show)
EndFunc

Func SpecialEvents()
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            Exit
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
                guisetstate(@SW_MINIMIZE)
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
                guisetstate(@SW_RESTORE)
    EndSelect
EndFunc

;Keep the window around
While 1
    Sleep(10)
Wend

I clipped out the stuff that currently works but has nothing to do with gui other than populating a few combo boxes. Now I've tried spawning the window as a child, I've tried creating it numerous places, and nothing gets it to come up when I click on the button. I'm using guisetonevent = 1 for this since I think it's cleaner which is a personal choice. Can someone point me in the right direction for making that second window pop-out? Yes I've tried setting the style of the window a be a popup but it still doesn't show. I could come up with a way around it, but I don't really see a need to do that :P. Thanks in advance!

Share this post


Link to post
Share on other sites



You used GuiSetOnEvent when you should have used GuiCtrlSetOnEvent. Take a look at both in the helpfiles to see the difference.

#include <GuiConstants.au3>

opt("GUIOnEventMode", 1)


;Build GUI here
$main = Guicreate("Character Tracking", 800, 600)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
guisetstate(@sw_show)

$addz = GuiCtrlCreateButton("Add New Zone", 10, 140)
GuiCtrlSetonEvent(-1, "AddZone")

$hWndZone = guicreate("Add Zone", 400,400)
GUISetState(@SW_HIDE)
GUISetOnEvent($GUI_EVENT_CLOSE,"SpecialEvents")


Func AddZone()
    guisetstate(@sw_show,$hWndZone)
EndFunc

Func SpecialEvents()
    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
                If @GUI_WinHandle = $hWndZone Then
                    GUISetState(@SW_HIDE,$hWndZone)
                Else
                    Exit 1
                EndIf
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
                guisetstate(@SW_MINIMIZE)
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
                guisetstate(@SW_RESTORE)
    EndSelect
EndFunc

;Keep the window around

While 1
    Sleep(200)
WEnd

Share this post


Link to post
Share on other sites

Nice catch, that resolved the issue!

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