Jump to content
Sign in to follow this  
slayerz

Child GUI as a button

Recommended Posts

slayerz

Hello guys...

I've searched the forum for an hour, but maybe I just missed the probable solution for this.

In a normal GUI, we can set GUICtrlSetOnHover() UDF for the button & etc, but is it possible to do the same for GUI? (not the control)

I'm facing this problem because I'm using multiple child GUI as my button (using PNG image), and I can't find the function that works just the same like GUICtrlSetOnHover() UDF.

So, if any of you had came across the same problem and had found the solution, plz let me know... :mellow:

Thanks,

slayerz


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites
BurakSZ

I don't really understood your problem. But here is something I found in the newest GUICtrlSetOnHover() version (Parent and Child GUI Example):

#include "GUICtrlOnHover.au3"

$hParent_GUI = GUICreate("Parent & Child Example", 280, 200)

$Parent_Button = GUICtrlCreateButton("Button", 20, 160, 100, 20)
_GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Leave_Hover_Func")

GUISetState()

$hChild_GUI = GUICreate("Child", 150, 100, -1, -1, -1, -1, $hParent_GUI)

$Child_Button = GUICtrlCreateButton("Button", 20, 20, 100, 20)
_GUICtrl_OnHoverRegister(-1, "_Hover_Func", "_Leave_Hover_Func")

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Parent_Button, $Child_Button
            If BitAND(WinGetState($hChild_GUI), 2) Then
                GUISetState(@SW_HIDE, $hChild_GUI)
            Else
                GUISetState(@SW_SHOW, $hChild_GUI)
            EndIf
    EndSwitch
WEnd

Func _Hover_Func($CtrlID)
    Switch $CtrlID
        Case $Parent_Button, $Child_Button
            If GUICtrlRead($CtrlID) <> "Show/Hide Child" Then GUICtrlSetData($CtrlID, "Show/Hide Child")
    EndSwitch
EndFunc

Func _Leave_Hover_Func($CtrlID)
    Switch $CtrlID
        Case $Parent_Button, $Child_Button
            If GUICtrlRead($CtrlID) <> "Button" Then GUICtrlSetData($CtrlID, "Button")
    EndSwitch
EndFunc

Greets

Parent & Child Example.au3

Share this post


Link to post
Share on other sites
slayerz

No, I already stated that I know about GUICtrlSetOnHover(). This is different, because I'm only using GUICreate,(no GUICtrlCreate...)

so I cannot use the UDF. If the mouse is hovering the GUI, I want it to trigger my function... same as in JAVA where we can detect whether the mouse is entering the GUI or leaving the GUI.

BTW, thanks for ur time :mellow:


AUTOIT[sup] I'm lovin' it![/sup]

Share this post


Link to post
Share on other sites
slayerz

For now, I only come up with this method...

HotKeySet("{ESC}", "close")

$x = 100
$y = 100

$GUI = GUICreate('', $x, $y)
GUISetState()

While 1
    Sleep(500)
    $mPos = GUIGetCursorInfo()

    If $mpos[0] > 0 And $mpos[0] < $x Then
        If $mpos[1] > 0 And $mpos[1] < $y Then ConsoleWrite("INSIDE THE GUI" & @LF)
    Else
        ConsoleWrite("OUTSIDE THE GUI" & @LF)
    EndIf
WEnd

Func close()
    Exit
EndFunc

Still finding a way to trigger the function without polling every second to check whether the cursor is hovering the GUI.

Any more ideas?


AUTOIT[sup] I'm lovin' it![/sup]

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.