delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
500 Users Online NOW
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback





Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi



Loremo - the 1.5 liter car coming in 2009




Startblatt.de






Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (2)


Call AnimateWindow the safe wayFormat this article printer-friendly!Bookmark function is only available for registered users!
Apply animations to your app when the OS supports it..
Product:
Delphi all versions
Category:
Win API
Skill Level:
Scoring:
Last Update:
11/06/2001
Search Keys:
delphi delphi3000 article borland vcl code-snippet AnimateWindow AnimateSafe Animation
Times Scored:
8
Visits:
4159
Uploader: Adam Lanzafame
Company: Lanzafame Software
Reference: N/A
 
Question/Problem/Abstract:
AnimateWindow is a API which can enhance your GUI by adding special animations to your forms. However, the API is not valid in all operating systems. It is only valid in Windows 98 / 2000 and >

This code shows you how to use AnimateWindow when (and only when) it is supported. Without crashing and burning when it is not supported.
Answer:



procedure AnimateSafe(hWnd: HWND; dwTime: DWord; dwFlags: DWord);
type
    d = function(a: THandle; b, c: DWord): Boolean; stdcall;
var
    e, f: integer;
    g: d;
begin
try
    e := LoadLibrary('user32.dll');
    if e = 0 then
        exit
    else
        begin
            g := GetProcAddress(e, 'AnimateWindow');
            if @g = nil then
                exit
            else
                begin
                    g(hWnd, dwTime, dwFlags);
                end;
        end;
finally
    FreeLibrary(e);
end;
end;

//Use AnimateSafe like:

procedure TForm1.FormCreate(Sender: TObject);
begin
    AnimateSafe(Handle, 300, AW_BLEND or AW_ACTIVATE);
    Self.Invalidate;
end;

(*

dwFlags can be:

AW_SLIDE
Uses slide animation. By default, roll animation is used. This flag is ignored when used with AW_CENTER.
AW_ACTIVATE
Activates the window. Do not use this value with AW_HIDE.
AW_BLEND
Uses a fade effect. This flag can be used only if hwnd is a top-level window.
AW_HIDE
Hides the window. By default, the window is shown.
AW_CENTER
Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used.
AW_HOR_POSITIVE
Animates the window from left to right. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.
AW_HOR_NEGATIVE
Animates the window from right to left. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.
AW_VER_POSITIVE
Animates the window from top to bottom. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.
AW_VER_NEGATIVE
Animates the window from bottom to top. This flag can be used with roll or slide animation. It is ignored when used with AW_CENTER or AW_BLEND.

*)





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
ok
    sdvf xvbb (May 25 2008 3:01PM)

  • youporn

  • redtube

  • pornhub

  • tube8

  • sex

  • Respond

    Isn't better?
        Christian Cristofori (Nov 6 2001 5:52PM)

    Isn't better write the code like this?

    Procedure AnimateSafe( hWnd : THandle; dwTime : DWord = 250; dwFlags : DWord = ( AW_BLEND Or AW_ACTIVATE ) );
    Type
      TAnimateWindowFunction = Function ( Handle : THandle; Delay, Flags : DWord ) : Boolean; StdCall;
    Var
      User32Library     : THandle;
      AnimateWindowProc : TAnimateWindowFunction;
    Begin
      User32Library := 0;
      Try
        User32Library := LoadLibrary( 'USER32.DLL' );
        If ( Not( User32Library = 0 ) ) Then Begin
          AnimateWindowProc := GetProcAddress( User32Library, 'AnimateWindow' );
          If Not( @AnimateWindowProc = NIL ) Then AnimateWindowProc( hWnd, dwTime, dwFlags );
        End;
      Finally
        If ( Not( User32Library = 0 ) ) Then FreeLibrary( User32Library );
      End;
    End;
    Respond

    RE: Isn't better?
    Eber Irigoyen (Nov 6 2001 6:57PM)

    indeed it is... but... wouldn't it be better to load the library and the function on the OnCreateForm event, then use the function as many times as needed, and then free everything on the OnDestroyForm??
    why load, execute and free everytime we need the effect?
    Respond














     
    Sign up to consume product discounts for Bronze memberships !

    read more


      Visit our Sponsor

     

      Community Ad of
    D. Wischnewski
     
       














     







         
      Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
    delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)