Jump to content
Sign in to follow this  
sensalim

GUI_CtrlHandle returns 0 all the time

Recommended Posts

sensalim

Never had problem with this before... this time I used Koda Form Designer but I checked every line and they seem fine.

Can anyone tell me what's wrong?

Code:

#include <GUIConstants.au3>
#include <Misc.au3>

;variables
$mwtitle       = "Main Window"
$mwwidth       = 244
$mwheight     = 490
Global $mwleft = @DESKTOPWIDTH - $mwwidth - 20
Global $mwtop  = @DESKTOPHEIGHT/2 - ($mwheight/2)
$w2title       = "Window 2"
$w2width       = 110
$w2height     = 30
Global $w2left = (@DESKTOPWIDTH/2) - 50
Global $w2top  = 15
;
;------------------------------------------------------------------------------

;singleton
If _singleton($mwtitle,1)=0 Then
    Exit
EndIf

;move mouse
MouseMove($mwleft+90, $mwtop+45, 1)

;change to OnEvent mode
Opt("GUIOnEventMode", 1)

;***MAIN WINDOW***
#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\SRP-CallResults.kxf
$mw = GUICreate($mwtitle, $mwwidth, $mwheight, $mwleft, $mwtop)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Radio1 = GUICtrlCreateRadio("Incoming Call", 8, 8, 81, 17)
GUICtrlSetOnEvent(-1, "Radio1Click")
$Radio2 = GUICtrlCreateRadio("Outgoing Call", 144, 8, 81, 17)
GUICtrlSetOnEvent(-1, "Radio2Click")
$Radio3 = GUICtrlCreateRadio("E-mail", 8, 24, 49, 17)
GUICtrlSetOnEvent(-1, "Radio3Click")
$Radio4 = GUICtrlCreateRadio("Meeting", 144, 24, 57, 17)
GUICtrlSetOnEvent(-1, "Radio4Click")
$Button1 = GUICtrlCreateButton("Supportive", 72, 57, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Purpose/Need", 16, 97, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("Benefits", 16, 129, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button3Click")
$Button4 = GUICtrlCreateButton("Aesthetics", 16, 161, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button4Click")
$Button5 = GUICtrlCreateButton("Health/Safety", 16, 193, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button5Click")
$Button6 = GUICtrlCreateButton("Environmental", 16, 225, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button6Click")
$Button7 = GUICtrlCreateButton("Noise", 16, 257, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button7Click")
$Button8 = GUICtrlCreateButton("Land", 120, 97, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button8Click")
$Button9 = GUICtrlCreateButton("Route Pref.", 120, 129, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button9Click")
$Button10 = GUICtrlCreateButton("Permitting Process", 120, 193, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button10Click")
$Button11 = GUICtrlCreateButton("Water", 120, 225, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button11Click")
$Button12 = GUICtrlCreateButton("Construction", 120, 257, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button12Click")
$Button13 = GUICtrlCreateButton("Other", 72, 289, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button13Click")
$Button14 = GUICtrlCreateButton("Speaker - Hearing", 72, 329, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button14Click")
$Button15 = GUICtrlCreateButton("Send Info", 72, 361, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button15Click")
$Button16 = GUICtrlCreateButton("Arrange 1-1 Meeting", 72, 393, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button16Click")
$Button17 = GUICtrlCreateButton("Arrange Call", 72, 425, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button17Click")
$Button18 = GUICtrlCreateButton("HOA President", 72, 457, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button18Click")
$Button19 = GUICtrlCreateButton("Project Update", 120, 160, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button19Click")
$Group1 = GUICtrlCreateGroup("Issue", 8, 80, 225, 241)
#EndRegion ### END Koda GUI section ###

;***MINI WINDOW***
$w2 = GUICreate($w2title, $w2width, $w2height, $w2left, $w2top)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button20 = GUICtrlCreateButton("Restore", 0, 0, 110, 30)
GUICtrlSetOnEvent(-1, "Button20Click")
GUISetState(@SW_SHOW, $w2)

;switch to main window and show it
GUISwitch($mw)
GUISetState(@SW_SHOW)

;set all windows "always on top"
SetAllWindowsAlwaysOnTop()

;idle around
While 1
    Sleep(100)
WEnd

Func SetAllWindowsAlwaysOnTop()
    WinSetOnTop($mw, "", 1)
    WinSetOnTop($w2, "", 1)
EndFunc
Func Button10Click()

EndFunc
Func Button11Click()

EndFunc
Func Button12Click()

EndFunc
Func Button13Click()

EndFunc
Func Button14Click()

EndFunc
Func Button15Click()

EndFunc
Func Button16Click()

EndFunc
Func Button17Click()

EndFunc
Func Button18Click()

EndFunc
Func Button19Click()

EndFunc
Func Button1Click()

EndFunc
Func Button2Click()

EndFunc
Func Button3Click()

EndFunc
Func Button4Click()

EndFunc
Func Button5Click()

EndFunc
Func Button6Click()

EndFunc
Func Button7Click()

EndFunc
Func Button8Click()

EndFunc
Func Button9Click()

EndFunc
Func Button20Click()
    GUISetState(@SW_HIDE, @GUI_WinHandle)
    GUISwitch($mw)
    GUISetState(@SW_SHOW, $mw)
EndFunc
Func Form1Close()
    MsgBox(0, "Closing", @GUI_CTRLHANDLE & " vs " & $mw)
    If @GUI_CTRLHANDLE = $mw Then
        MsgBox(0, "Mini", "Activating mini...")
;minimize and focus to mini window
        GUISetState(@SW_HIDE, $mw)
        GUISwitch($w2)
        GUISetState(@SW_SHOW, $w2)
    ElseIf @GUI_CTRLHANDLE = $w2 Then
;ask for closing confirmation
        $a = MsgBox(4, "Really Exit?", "Really close?", 30)
        If $a = 6 Then
    ;Save coordinates of both windows before exiting
            Exit
        EndIf
    Else
;unknown
        MsgBox(0, "Error 001", "@GUI_CTRLHANDLE error")
        Exit
    EndIf
EndFunc
Func Radio1Click()

EndFunc
Func Radio2Click()

EndFunc
Func Radio3Click()

EndFunc
Func Radio4Click()

EndFunc
Edited by sensalim

Share this post


Link to post
Share on other sites
BrettF

What are you having a problem with?

#include <GUIConstants.au3>
#include <Misc.au3>

;variables
$mwtitle       = "Main Window"
$mwwidth       = 244
$mwheight     = 490
Global $mwleft = @DESKTOPWIDTH - $mwwidth - 20
Global $mwtop  = @DESKTOPHEIGHT/2 - ($mwheight/2)
$w2title       = "Window 2"
$w2width       = 110
$w2height     = 30
Global $w2left = (@DESKTOPWIDTH/2) - 50
Global $w2top  = 15
;
;------------------------------------------------------------------------------

;singleton
If _singleton($mwtitle,1)=0 Then
    Exit
EndIf

;move mouse
MouseMove($mwleft+90, $mwtop+45, 1)

;change to OnEvent mode
Opt("GUIOnEventMode", 1)

;***MAIN WINDOW***
#Region ### START Koda GUI section ### Form=C:\Program Files\AutoIt3\SciTE\Koda\Forms\SRP-CallResults.kxf
$mw = GUICreate($mwtitle, $mwwidth, $mwheight, $mwleft, $mwtop)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Radio1 = GUICtrlCreateRadio("Incoming Call", 8, 8, 81, 17)
GUICtrlSetOnEvent(-1, "Radio1Click")
$Radio2 = GUICtrlCreateRadio("Outgoing Call", 144, 8, 81, 17)
GUICtrlSetOnEvent(-1, "Radio2Click")
$Radio3 = GUICtrlCreateRadio("E-mail", 8, 24, 49, 17)
GUICtrlSetOnEvent(-1, "Radio3Click")
$Radio4 = GUICtrlCreateRadio("Meeting", 144, 24, 57, 17)
GUICtrlSetOnEvent(-1, "Radio4Click")
$Button1 = GUICtrlCreateButton("Supportive", 72, 57, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("Purpose/Need", 16, 97, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button2Click")
$Button3 = GUICtrlCreateButton("Benefits", 16, 129, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button3Click")
$Button4 = GUICtrlCreateButton("Aesthetics", 16, 161, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button4Click")
$Button5 = GUICtrlCreateButton("Health/Safety", 16, 193, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button5Click")
$Button6 = GUICtrlCreateButton("Environmental", 16, 225, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button6Click")
$Button7 = GUICtrlCreateButton("Noise", 16, 257, 100, 25, 0)
GUICtrlSetOnEvent(-1, "Button7Click")
$Button8 = GUICtrlCreateButton("Land", 120, 97, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button8Click")
$Button9 = GUICtrlCreateButton("Route Pref.", 120, 129, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button9Click")
$Button10 = GUICtrlCreateButton("Permitting Process", 120, 193, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button10Click")
$Button11 = GUICtrlCreateButton("Water", 120, 225, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button11Click")
$Button12 = GUICtrlCreateButton("Construction", 120, 257, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button12Click")
$Button13 = GUICtrlCreateButton("Other", 72, 289, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button13Click")
$Button14 = GUICtrlCreateButton("Speaker - Hearing", 72, 329, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button14Click")
$Button15 = GUICtrlCreateButton("Send Info", 72, 361, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button15Click")
$Button16 = GUICtrlCreateButton("Arrange 1-1 Meeting", 72, 393, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button16Click")
$Button17 = GUICtrlCreateButton("Arrange Call", 72, 425, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button17Click")
$Button18 = GUICtrlCreateButton("HOA President", 72, 457, 106, 25, 0)
GUICtrlSetOnEvent(-1, "Button18Click")
$Button19 = GUICtrlCreateButton("Project Update", 120, 160, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button19Click")
$Group1 = GUICtrlCreateGroup("Issue", 8, 80, 225, 241)
#EndRegion ### END Koda GUI section ###

;***MINI WINDOW***
$w2 = GUICreate($w2title, $w2width, $w2height, $w2left, $w2top)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button20 = GUICtrlCreateButton("Restore", 0, 0, 110, 30)
GUICtrlSetOnEvent(-1, "Button20Click")
GUISetState(@SW_SHOW, $w2)

;switch to main window and show it
GUISwitch($mw)
GUISetState(@SW_SHOW)

;set all windows "always on top"
SetAllWindowsAlwaysOnTop()

;idle around
While 1
    Sleep(100)
WEnd

Func SetAllWindowsAlwaysOnTop()
    WinSetOnTop($mw, "", 1)
    WinSetOnTop($w2, "", 1)
EndFunc
Func Button10Click()

EndFunc
Func Button11Click()

EndFunc
Func Button12Click()

EndFunc
Func Button13Click()

EndFunc
Func Button14Click()

EndFunc
Func Button15Click()

EndFunc
Func Button16Click()

EndFunc
Func Button17Click()

EndFunc
Func Button18Click()

EndFunc
Func Button19Click()

EndFunc
Func Button1Click()

EndFunc
Func Button2Click()

EndFunc
Func Button3Click()

EndFunc
Func Button4Click()

EndFunc
Func Button5Click()

EndFunc
Func Button6Click()

EndFunc
Func Button7Click()

EndFunc
Func Button8Click()

EndFunc
Func Button9Click()

EndFunc
Func Button20Click()
    GUISetState(@SW_HIDE, @GUI_WinHandle)
    GUISwitch($mw)
    GUISetState(@SW_SHOW, $mw)
EndFunc
Func Form1Close()
    MsgBox(0, "Closing", @GUI_WinHandle & " vs " & $mw)
    If @GUI_WinHandle = $mw Then
        MsgBox(0, "Mini", "Activating mini...")
   ;minimize and focus to mini window
        GUISetState(@SW_HIDE, $mw)
        GUISwitch($w2)
        GUISetState(@SW_SHOW, $w2)
    ElseIf @GUI_WinHandle = $w2 Then
   ;ask for closing confirmation
        $a = MsgBox(4, "Really Exit?", "Really close?", 30)
        If $a = 6 Then
       ;Save coordinates of both windows before exiting
            Exit
        EndIf
    Else
   ;unknown
        MsgBox(0, "Error 001", "@GUI_CTRLHANDLE error")
        Exit
    EndIf
EndFunc
Func Radio1Click()

EndFunc
Func Radio2Click()

EndFunc
Func Radio3Click()

EndFunc
Func Radio4Click()

EndFunc

You needed @GUI_WinHandle instead of @GUI_CTRLHANDLE

Edited by Bert

Share this post


Link to post
Share on other sites
sensalim

Oh geez. I'm a stoop1d head :D.

Thanks.

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  

×