본문 바로가기

프로그래밍/Delphi

AnimateWindow API를 이용한 델파이 콘트롤 애니메이션 효과

델파이의 콘트롤들은 모두 TWinControl을 상속 받는데 이 콘트롤들은 윈도우의 애니메이션 API인 "AnimateWindow"를 이용하여 여러가지 애니메이션 효과를 줄 수 있다.


예를 들어 판넬(Panel)에 대해서 Hide, Slide, Fade 등의 효과를 줄 수 있다


AnimateWindow API 정의


function AnimateWindow(hwnd : HWND; dwTime : DWORD; dwFlags : DWORD);


- hwnd : 애니메이션을 주고 싶은 콘트롤의 핸들

- dwTime : 애니메이션 효과를 주는 시간으로 밀리세컨드 단위로 준다 일반적으로 200 millisecond가 적당

- dwFlag : 애니메이션 효과 구분으로 다음과 같이 정의됨


Value

Meaning

AW_ACTIVATE

0x00020000

Activates the window. Do not use this value with AW_HIDE.

AW_BLEND

0x00080000

Uses a fade effect. This flag can be used only if hwnd is a top-level window.

AW_CENTER

0x00000010

Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used. The various direction flags have no effect.

AW_HIDE

0x00010000

Hides the window. By default, the window is shown.

AW_HOR_POSITIVE

0x00000001

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

0x00000002

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_SLIDE

0x00040000

Uses slide animation. By default, roll animation is used. This flag is ignored when used with AW_CENTER.

AW_VER_POSITIVE

0x00000004

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

0x00000008

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.



사용예)   

. 판넬을 위에서 아래로 슬라이딩 시키고 숨기는 예


animatewindow-delphi.zip


AnimateWindow(Panel1.Handle, 200, AW_VER_NEGATIVE OR AW_SLIDE OR AW_HIDE);


      . 판넬을 안쪽으로 사라지게 만드는 예


AnimateWindow(Panel1.Handle, 200, AW_CENTER OR AW_HIDE);