Jump to content
Sign in to follow this  
biase

Slide animation in and out problem

Recommended Posts

biase

I have a gui which hidden on the right screen, and it will slide out from right to left if the mouse is hovered at the right screen, but I'm having trouble with slide in which will hide the gui back to the right screen. I've tried for 3 hours making it to works but failed.

Hope some one can help me and make a good use of this piece of code

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#NoTrayIcon

Global $sout = False
$Main = GUICreate("Slider", 500, (@DesktopHeight - _TaskBarHeight()), @DesktopWidth, -1, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$BgPic = GUICtrlCreatePic('background.jpg', 0, 0, 0, 0)
GUICtrlSetState($BgPic, $GUI_DISABLE)
GUISetState(@SW_HIDE, $Main)

While 1 * Sleep(100)
$nMsg = GUIGetMsg(1)
$MPos = MouseGetPos()
$GPos = WinGetClientSize($Main)
Select
Case $nMsg[0] = -3
Exit
EndSelect
If $MPos[0] >= (@DesktopWidth - 1) Then
If Not $sout Then
$sout = True
;WinMove($Main, "", (@DesktopWidth - $GPos[0]), 0, $GPos[0], @DesktopHeight, 2)
WinMove($Main, "", (@DesktopWidth - $GPos[0]), 0)
WinSetTrans($Main, 0, 235)
WinSetOnTop($Main, "", 1)
Else
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00040002);slide in from right = show
GUISetState(@SW_SHOW, $Main)
EndIf
EndIf
If Not _isGuiHover() Then
If $sout Then
$sout = False
;WinMove($Main, "", @DesktopWidth, 0, $GPos[0], @DesktopHeight, 2)
WinMove($Main, "", @DesktopWidth, 0)
WinSetOnTop($Main, "", 0)
Else
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00050002);slide out to left = hide
GUISetState(@SW_HIDE, $Main)
EndIf
EndIf
WEnd

Func _isGuiHover()
Local $m = MouseGetPos(), $p = WinGetPos($Main)
If $m[0] > $p[0] Then
Return 1
Else
Return 0
EndIf
EndFunc ;==>_isGuiHover

Func _TaskBarHeight()
Local $aPos = WinGetPos("[CLASS:Shell_TrayWnd; W:" & @DesktopWidth & "]")
Return $aPos[3]
EndFunc ;==>_TaskBarHeight

Below are the file with the images i use

Slide.rar

Share this post


Link to post
Share on other sites
Melba23

biase,

You were overcomplicating things - and you misunderstood the slide in/out directions (they are not easy to interpret): ;)

Try this:

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Global $sout = False
$Main = GUICreate("Slider", 500, (@DesktopHeight - _TaskBarHeight()), @DesktopWidth - 500, -1, BitOR($WS_SYSMENU, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$BgPic = GUICtrlCreatePic('background.jpg', 0, 0, 0, 0)
GUICtrlSetState($BgPic, $GUI_DISABLE)

While 1
    $nMsg = GUIGetMsg()
    $MPos = MouseGetPos()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        Case $MPos[0] >= (@DesktopWidth - 1) And Not $sout
            $sout = True
            DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00040002) ; $AW_SLIDE_IN_RIGHT
        Case $MPos[0] < (@DesktopWidth - 500) And $sout
            $sout = False
            DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Main, "int", 270, "long", 0x00050001) ; $AW_SLIDE_OUT_RIGHT
    EndSelect
WEnd

Func _TaskBarHeight()
    Local $aPos = WinGetPos("[CLASS:Shell_TrayWnd; W:" & @DesktopWidth & "]")
    Return $aPos[3]
EndFunc   ;==>_TaskBarHeight

Any better? :)

M23

  • Like 1

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
biase

Thanks alot, it works like a charm and the code much smaller.

You're correct about the "misunderstood the slide directions". It's give me a headcahe once... :wacko:

Share this post


Link to post
Share on other sites
Melba23

biase,

You're correct about the "misunderstood the slide directions". It's give me a headcahe once...

Me too the first time - and I still have to check now! :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×