Champak Posted February 22, 2008 Posted February 22, 2008 Is it possible to make a GUI/Window do a type of drop down/slide effect? Basically I want a GUI that will actually be a big menu, that will only initially show about a quarter of the actual window, and if I press a button, the rest of the window, based on whichever button I press, will drop down like a menu...or like those nice new phones. I've searched and haven't seen any reference to this....animation/slide/dropdown...I see nothing. So is this possible? I've made a clunky workaround where I have two separate GUIs and one appears from behind the other one and slides down, but it has a couple issues that I can't resolve, and it just doesn't look as nice as I believe is possible....if this is possible. Anyone? Thanks.
weaponx Posted February 22, 2008 Posted February 22, 2008 Not really sure what you mean. Maybe something like this: expandcollapse popup#include <GUIConstants.au3> Opt("GUIOnEventMode", 1) Global $startWidth = 200, $startHeight = 200 Global $endWidth = $startWidth, $endHeight = 400 GUICreate("My GUI",$startWidth ,$startHeight) ; will create a dialog box that when displayed is centered GUISetOnEvent($GUI_EVENT_CLOSE, "Close") GUISetState (@SW_SHOW) ; will display an empty dialog box ;Draw Expand/Contract buttons on top of each other (hide Contract button initially) $buttonExpand = GuiCtrlCreateButton("Expand", 70, 170,60, 20) GUICtrlSetOnEvent($buttonExpand, "expand") $buttonContract = GuiCtrlCreateButton("Contract", 70, 170,60, 20) GUICtrlSetState ($buttonContract, $GUI_HIDE) GUICtrlSetOnEvent($buttonContract, "contract") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Wend Func expand() ;Expand vertically, 6 pixels at a time For $X = $startHeight to $endHeight Step 6 WinMove ("","", default,default,$startWidth,$X) ;Sleep 0=Fastest, 5=Slowest Sleep(PixelsToPercent($startHeight,$X,$endHeight) * 5) Next GUICtrlSetState ($buttonExpand, $GUI_HIDE) GUICtrlSetState ($buttonContract, $GUI_SHOW) EndFunc Func contract() ;Contract vertically, 6 pixels at a time For $X = $endHeight to $startHeight Step -6 WinMove ("","", default,default,$startWidth,$X) ;Sleep 0=Fastest, 5=Slowest Sleep(PixelsToPercent($startHeight,$X,$endHeight) * 5) Next GUICtrlSetState ($buttonExpand, $GUI_SHOW) GUICtrlSetState ($buttonContract, $GUI_HIDE) EndFunc ;Convert pixel width or height to relative percentage difference (Min = 0%, Max = 100%) Func PixelsToPercent($min, $current, $max) ;Return value from 0-1 Return ($current-$min) / ($max-$min) EndFunc Func Close() Exit EndFunc
Siao Posted February 22, 2008 Posted February 22, 2008 Also search forum for "AnimateWindow" "be smart, drink your wine"
Champak Posted February 23, 2008 Author Posted February 23, 2008 (edited) Thanks both. I solved my problem. I just had to play with how I had everything set up. It isn't exactly how I want, because you can see a border between the two GUIs. What would really solve my problem now is if I can specify which border will show or not. That way when I have the other GUI drop down from behind, I could specify that the bottom border of the menu GUI and the top portion of the GUI I have appearing not show. Is this possible? Siao, I was using that from the beginning, as I said just now, but I couldn't get it to appear and function how I wanted, which was the reason for my initial post. So here is a basic example of what I'm doing. Using AnimateWindow and Sliding Toolbar. But would be great to solve my question (Paragraph 1). expandcollapse popup#include <GuiConstants.au3> Global Const $AW_FADE_IN = 0x00080000;fade-in Global Const $AW_FADE_OUT = 0x00090000;fade-out Global Const $AW_SLIDE_IN_TOP = 0x00040004;slide-in from top Global Const $AW_SLIDE_OUT_TOP = 0x00050008;slide-out to top Global $YCoord = 250;Y Coordinates of all the windows $AppTitle = "Application" $MediaGUI = GuiCreate($AppTitle, 600, 300, 0, $YCoord+86, $WS_POPUP+$WS_BORDER,BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetBkColor(0xffff) GUISetState(@SW_HIDE) $MediaGUI2 = GuiCreate($AppTitle, 600, 300, 0, $YCoord+86, $WS_POPUP+$WS_BORDER,BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) GUISetBkColor(0xffffff) GUISetState(@SW_HIDE) ;;;;MENU GUI $Slide1 = GUICreate("Sliding Toolbar", 600, 85, -575, $YCoord, $WS_POPUP+$WS_BORDER, BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) $Show = GUICtrlCreateButton(">", 570, 8, 27, 70, BitOR($BS_CENTER, $BS_FLAT)) GUISetState() $Slide2 = GUICreate("Sliding Toolbar", 600, 85, 0, $YCoord, $WS_POPUP+$WS_BORDER, BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW)) $Button1 = GUICtrlCreateButton("Button 1", 10, 35, 73, 41) $Button2 = GUICtrlCreateButton("Button 2", 90, 35, 73, 41) $Hide = GUICtrlCreateButton("<", 570, 8, 27, 70, BitOR($BS_CENTER, $BS_FLAT)) ;GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $Show Slide_in() Case $msg = $Hide $Button1Active = WinGetState($MediaGUI) If $Button1Active = 7 Then _WinAnimate($MediaGUI, $AW_SLIDE_OUT_TOP, 700) EndIf $Button2Active = WinGetState($MediaGUI2) If $Button2Active = 7 Then _WinAnimate($MediaGUI2, $AW_SLIDE_OUT_TOP, 700) EndIf Slide_out() Case $msg = $Button1 $Button2Active = WinGetState($MediaGUI2) If $Button2Active = 7 Then _WinAnimate($MediaGUI2, $AW_SLIDE_OUT_TOP, 700) EndIf Sleep(100);So it looks a little smoother in the exchange $Button1Active = WinGetState($MediaGUI) If $Button1Active = 5 Then _WinAnimate($MediaGUI, $AW_SLIDE_IN_TOP, 800) GUISetState(@SW_SHOW,$MediaGUI) WinActivate($MediaGUI) ; _WinAnimate($MediaGUI, $AW_FADE_IN, 800) Else _WinAnimate($MediaGUI, $AW_SLIDE_OUT_TOP, 800) EndIf Case $msg = $Button2 $Button1Active = WinGetState($MediaGUI) If $Button1Active = 7 Then _WinAnimate($MediaGUI, $AW_SLIDE_OUT_TOP, 700) EndIf Sleep(100);So it looks a little smoother in the exchange $Button2Active = WinGetState($MediaGUI2) If $Button2Active = 5 Then _WinAnimate($MediaGUI2, $AW_SLIDE_IN_TOP, 800) GUISetState(@SW_SHOW,$MediaGUI2) WinActivate($MediaGUI2) ; _WinAnimate($MediaGUI, $AW_FADE_IN, 800) Else _WinAnimate($MediaGUI2, $AW_SLIDE_OUT_TOP, 800) EndIf EndSelect WEnd Func Slide_in() DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Slide1, "int", 0, "long", 0x00050002);slide out to left DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Slide2, "int", 625, "long", 0x00040001);slide in from left ;WinActivate($Slide2) ;WinWaitActive($Slide2) GuiSetState(@SW_SHOW,$Slide2);Have to put this in otherwise video window will pop up EndFunc ;==>Slide_in Func Slide_out() ; WinMove($hwnd, "", -500, 250) DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Slide2, "int", 625, "long", 0x00050002);slide out to left DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $Slide1, "int", 0, "long", 0x00040001);slide in from left ;WinActivate($Slide1) ;WinWaitActive($Slide1) GuiSetState(@SW_SHOW,$Slide1);Have to put this in otherwise video window will pop up EndFunc ;==>Slide_out Func _WinAnimate($v_gui, $i_mode, $i_duration = 1000) If @OSVersion = "WIN_XP" OR @OSVersion = "WIN_2000" Then DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($v_gui), "int", $i_duration, "long", $i_mode) Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError') If $ai_gle[0] <> 0 Then SetError(1) Return 0 EndIf Return 1 EndIf EndFunc;==> _WinAnimate() Also, is there a way to combine the animation? I would like to combine the slide with the fade. Edited February 23, 2008 by Champak
flyingboz Posted February 23, 2008 Posted February 23, 2008 There are some examples of "toast" floating around that you may find useful. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.
Siao Posted February 23, 2008 Posted February 23, 2008 Champak said: Also, is there a way to combine the animation? I would like to combine the slide with the fade.Use BitOr() to combine the animation mode flags. "be smart, drink your wine"
Champak Posted February 23, 2008 Author Posted February 23, 2008 (edited) flyingboz, What is "toast"? I did a search and didn't find any relevant info. Which one of my issues is it to resolve, the combination of the animation types, or the line separating the GUIs? Siao, I've tried that before. Both BitAND and BitOr, neither work. I tried setting it as the global constant and putting it in the actual call...unless I did it wrong. Global Const $FadeInSlideIn = BitOR(0x00080000,0x00040004) On both of them, one effect just overrides the other. Edited February 23, 2008 by Champak
crashdemons Posted April 9, 2008 Posted April 9, 2008 (edited) Champak said: What is "toast"? I did a search and didn't find any relevant info. Toast is just a notification window - usually without any title bar or major controls. Traditionally it pops up/slides up from around the "Tray" area of the taskbar from off-screen. Wikipedia: Toast (computing) I made a crappy myToast.au3 that just uses a WS_POPUP with a "border" (if you can call it a border ) without _WinAnimate But it does support a user-defined window... expandcollapse popup#cs TITLE TOAST CUSTOM AUTHOR Crash Daemonicus VERSION 1.59 #ce Global $temp_ToastForm, $temp_ToastBox Func ToastWin_Create($text,$x,$y,$w=100,$h=100,$Wrap=True, $Border=0x00FF00,$Back=0x000000) Global $temp_ToastForm, $temp_ToastBox $text=' '&StringReplace($text,@CRLF,' '&@CRLF) #Region ### START Koda GUI section ### Form=form.kxf $Form = GUICreate("CD_TOASTWIN", 100, 100, $x, $y, $WS_POPUP,$WS_EX_TOPMOST+$WS_EX_TOOLWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE,"ToastWin_DisposeAuto",$Form) GUISetBkColor($Border) $Style=$SS_LEFTNOWORDWRAP If $Wrap Then $Style=$SS_LEFT $Label = GUICtrlCreateLabel($text, 1, 1, 100-2, 100-2,$Style) GUICtrlSetResizing (-1, 2+4+32+64) GUICtrlSetColor(-1, $Border) GUICtrlSetBkColor(-1, $Back) GUICtrlSetOnEvent($Label,"ToastWin_DisposeAuto") #EndRegion ### END Koda GUI section ### GUISetState(@SW_HIDE,$Form) ToastWin_Size($Form,$w,$h) $temp_ToastBox=$Label $temp_ToastForm=$Form Return $Form EndFunc Func ToastWin_Set($ToastGUI,$CloseCtrl=-1) ;For a custom GUI - this just sets information for the Close event ( ToastWin_DisposeAuto ) ; ToastGUI is the handle returned by GUICreate ; CloseCtrl is the controlID of a control on the ToastGUI ; |- - to be used as a Click-To-Close control. Global $temp_ToastForm $temp_ToastForm=$ToastGUI GUISetOnEvent($GUI_EVENT_CLOSE,"ToastWin_DisposeAuto",$ToastGUI) If $CloseCtrl<>-1 Then GUICtrlSetOnEvent($CloseCtrl,"ToastWin_DisposeAuto") EndIf Return $ToastGUI EndFunc Func ToastWin_Show($Toast,$show=True) If WinExists($Toast)=0 Then Return If $show Then GUISetState(@SW_SHOW,$Toast) Else GUISetState(@SW_HIDE,$Toast) EndIf EndFunc Func ToastWin_PrepFade($Toast) If WinExists($Toast)=0 Then Return WinSetTrans($Toast,'',0) GUISetState(@SW_SHOW,$Toast) EndFunc Func ToastWin_Fade($Toast,$start=0,$end=255,$speed=50,$spdel=50) If WinExists($Toast)=0 Then Return WinSetTrans($Toast,'',$start) If $end<$start Then $speed*=-1 For $i=$start To $end Step $speed ; there's no need to use acceleration with fades so I'll keep the for loop (see the do-until's below) WinSetTrans($Toast,'',$i) sleep($spdel) Next WinSetTrans($Toast,'',$end) EndFunc Func ToastWin_OpenOut($Toast,$start=0,$end=255,$speed=1,$spdel=50) If WinExists($Toast)=0 Then Return $ap=WinGetPos($Toast,'') WinMove($Toast,'',$ap[0],$ap[1],$start,$ap[3]) $i=$start If $end<$start Then $speed*=-1 $ii=$speed Do WinMove($Toast,'',$ap[0],$ap[1],$i,$ap[3]) $ii*=2 $i+=$ii Sleep($spdel) Until ($end<$start and $i<=$end) Or ($end>$start and $i>=$end) WinMove($Toast,'',$ap[0],$ap[1],$end,$ap[3]) EndFunc Func ToastWin_OpenDown($Toast,$start=0,$end=255,$speed=1,$spdel=50) If WinExists($Toast)=0 Then Return $ap=WinGetPos($Toast,'') WinMove($Toast,'',$ap[0],$ap[1],$ap[2],$start) $i=$start If $end<$start Then $speed*=-1 $ii=$speed Do WinMove($Toast,'',$ap[0],$ap[1],$ap[2],$i) $ii*=2 $i+=$ii Sleep($spdel) Until ($end<$start and $i<=$end) Or ($end>$start and $i>=$end) WinMove($Toast,'',$ap[0],$ap[1],$ap[2],$end) EndFunc Func ToastWin_SlideOut($Toast,$start=0,$end=255,$speed=1,$spdel=50) If WinExists($Toast)=0 Then Return $ap=WinGetPos($Toast,'') WinMove($Toast,'',$start,$ap[1]) $i=$start If $end<$start Then $speed*=-1 $ii=$speed Do WinMove($Toast,'',$i,$ap[1]) $ii*=2 $i+=$ii Sleep($spdel) Until ($end<$start and $i<=$end) Or ($end>$start and $i>=$end) WinMove($Toast,'',$end,$ap[1]) EndFunc Func ToastWin_SlideDown($Toast,$start=0,$end=255,$speed=1,$spdel=50) If WinExists($Toast)=0 Then Return $ap=WinGetPos($Toast,'') WinMove($Toast,'',$ap[0],$start) $i=$start If $end<$start Then $speed*=-1 $ii=$speed Do WinMove($Toast,'',$ap[0],$i) $ii*=2 $i+=$ii Sleep($spdel) Until ($end<$start and $i<=$end) Or ($end>$start and $i>=$end) WinMove($Toast,'',$ap[0],$end) EndFunc Func ToastWin_Explode($Toast,$speed=40,$spdel=20) If WinExists($Toast)=0 Then Return $ap=WinGetPos($Toast,'') $trans=255 For $i=0 To 255 WinSetTrans($Toast,'',$trans) WinMove($Toast,'',$ap[0],$ap[1],$ap[2],$ap[3]) $trans-=$speed $ap[2]+=$speed $ap[3]+=$speed If $trans<0 Then ExitLoop sleep($spdel) Next EndFunc Func ToastWin_Move($Toast,$x=-1,$y=-1) If WinExists($Toast)=0 Then Return $ap=WinGetPos($Toast,'') If $x=-1 Then $x=$ap[0] If $y=-1 Then $y=$ap[1] WinMove($Toast,'',$x,$y) EndFunc Func ToastWin_Size($Toast,$w=-1,$h=-1) If WinExists($Toast)=0 Then Return $ap=WinGetPos($Toast,'') If $w=-1 Then $w=$ap[2] If $h=-1 Then $h=$ap[3] WinMove($Toast,'',$ap[0],$ap[1],$w,$h) EndFunc Func ToastWin_DisposeAuto() ;just here for the close event Global $temp_ToastForm ToastWin_Explode($temp_ToastForm,40,20) GUIDelete($temp_ToastForm) EndFunc Func ToastWin_Sleep($Toast,$i,$spdel=50) ;normal Sleep, but taking into account Toast Existance ;This allows the Toast idle to terminate if the Toast is Closed If WinExists($Toast)=0 Then Return While WinExists($Toast)=1 And $i>$spdel Sleep($spdel) $i-=$spdel WEnd If WinExists($Toast)=1 And $i>0 Then Sleep($i) EndFunc Edited April 9, 2008 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now