Sign in to follow this  
Followers 0
John117

Need Help fixing my code. (if then problem I think)

1 post in this topic

#1 ·  Posted (edited)

Can someone please get this to work on the top, bottom and right side. -it will close if you are off the gui to the right but not the rest . . . .:)

Global $ParentWin_Width = 450
Global $ParentWin_Height = 700
Global $ParentWin_Left = ((@DesktopWidth - $ParentWin_Width) / 2)
Global $Top = 25
Global $ParentWin = GUICreate("Example", 450, $ParentWin_Height, $ParentWin_Left, $Top)
Opt("GUIOnEventMode", 1)
HotKeySet("{ESC}", "_Custom_Exit")
GUISetState(@SW_SHOW, $ParentWin)

While 1
    Sleep(1000)
    Global $size = WinGetPos($ParentWin)
    Global $pos = MouseGetPos()
    
    ;MouseLeft < GuiLeft
    If $pos[0] > $size[0] Then
        ;MouseRight > GuiRight
        If $pos[0] < ($size[0] + $size[2]) Then
            ;MouseTop < GuiTop
            If $pos[1] > $size[1] Then
                ;MouseBottom > GuiBottom
                If $pos[1] < ($size[1] + 500) Then
                     _Expand()
                Else
                    ;MsgBox(0, "if 4", "NotWorking")
                    _Colapse()
                EndIf
            Else
                ;MsgBox(0, "if 3", "NotWorking")
                _Colapse()
            EndIf
        Else
            ;MsgBox(0, "if 2", "NotWorking")
            _Colapse()
        EndIf
    Else
        ;MsgBox(0, "if 1", "NotWorking")
        _Colapse()
    EndIf
WEnd

Func _Colapse()
    ;WinMove ( "title", "text", x, y [, width [, height[, speed]]] )
        If $size[3] > 40 Then
    For $i = $ParentWin_Height To 40 Step - 5
        WinMove($ParentWin, "", $size[0], $size[1], $size[2], $i)
    Next
    EndIF
EndFunc   ;==>_Colapse
Func _Expand()
    ;MsgBox(0, "if 5", "working")
    If $size[3] = 40 Then
        For $i = 40 To $ParentWin_Height Step 5
            WinMove($ParentWin, "", $size[0], $size[1], $size[2], $i)
        Next
        EndIf
EndFunc   ;==>_Expand

Func _Custom_Exit()
    Exit
EndFunc ;==> _exit()
Edited by Hatcheda

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