Animate a Window.

vis781

Well-known member
Joined
Aug 30, 2005
Messages
2,016
Location
Cambridge, UK
Programming Experience
5-10
Any one ever used a timer to fade a window into view? or how about thought it would be cool to have their window unfold or slide into view just like the context menu can? Well look no further because you can do it too and with one Enum and about 2 lines of code. Interested? Well i'm going to make myself sound like an idiot now, but i've left the code for it at home, which i'll post this evening, sorry. However if you fancy looking for it yourself, you'll need the followng.....


AnimateWindowFlags - Enumeration
AnimateWindow - API
 
VB.NET:
Public Enum AW_Flags
AW_HOR_POSITIVE = &H1
AW_HOR_NEGATIVE = &H2
AW_VER_POSITIVE = &H4
AW_VER_NEGATIVE = &H8
AW_CENTER = &H10
AW_HIDE = &H10000
AW_ACTIVATE = &H20000
AW_SLIDE = &H40000
AW_BLEND = &H80000
AW_DURATION_DEFAULT = 200
End Enum
 
<DllImport(User32.Dll")> _
Public Shared Function AnimateWindow (ByVal hwnd As Intptr, _
ByVal dwTime As Integer, _
ByVal dwFlags As AW_Flags) As Integer
 
If we're talking about animation, I have one question. I once saw a small app which, when closed, broke into 4 pieces, and each piece "flew" towards a corner of the desktop. Any ideas on that pls?
 
Without giving it a go it would be hard to guess, but i would say that the the main form is probably hidden and several bitmaps are drawn onto the desktop window then animated off the screen. Or possibly, a larger transparent form is the app's main window and the UI that you see is just a child window, when the app closes the child form is closed and again several bitmaps are animated off the screen. There could many ways to implement this, and with a bit of multithreading i don't think it would be too difficult.
 
Back
Top