Animation of Windows
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Animation of Windows
I am trying to make some alert message dialogs, which pop up (sliding upwards) in the right bottom corner of the screen, like some instant messengers do.
I am trying with the AnimateWindow( HWND hWnd, DWORD dwTime, DWORD dwFlags) of user32.dll. Borland's winuser.h has the constants and prototype of this function.
I am able to close a window with animation effects by calling this function in the valid clause. But actually I want to activate a window with the animation. ON INIT is of no use because bInit is evaluated after the window is shown. I think this animatewindow should be used in the Activate method instead of the Showwindow function. Perhaps it would be a lot nicer if we can specify the animation type in the cShow parameter of the Activate method and the Activate method responds to it.
Any advice about how can I accomplish this?
I am trying with the AnimateWindow( HWND hWnd, DWORD dwTime, DWORD dwFlags) of user32.dll. Borland's winuser.h has the constants and prototype of this function.
I am able to close a window with animation effects by calling this function in the valid clause. But actually I want to activate a window with the animation. ON INIT is of no use because bInit is evaluated after the window is shown. I think this animatewindow should be used in the Activate method instead of the Showwindow function. Perhaps it would be a lot nicer if we can specify the animation type in the cShow parameter of the Activate method and the Activate method responds to it.
Any advice about how can I accomplish this?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Code: Select all
#include "FiveWin.ch"
#define AW_HOR_POSITIVE 0x00000001
#define AW_HOR_NEGATIVE 0x00000002
#define AW_VER_POSITIVE 0x00000004
#define AW_VER_NEGATIVE 0x00000008
#define AW_CENTER 0x00000010
#define AW_HIDE 0x00010000
#define AW_ACTIVATE 0x00020000
#define AW_SLIDE 0x00040000
#define AW_BLEND 0x00080000
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Test"
AnimateWindow( oWnd:hWnd, 600, nOr( AW_SLIDE, AW_HOR_POSITIVE ) )
ACTIVATE WINDOW oWnd ;
ON INIT oWnd:Refresh()
return nil
DLL FUNCTION AnimateWindow( hWnd AS LONG, nTime AS LONG, nFlags AS LONG ) AS BOOL PASCAL ;
LIB "user32.dll"
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
So far my observations:
1) Animation is not working with dialogs. Even with bStart.
2) Working with windows both while opening and closing. While opening, both AW_SLIDE and AW_ACTIVATE are giving the same effect. While closing we need to set flags to AW_HIDE. ( or'd with direction flag ofcourse).
3) Important: While hiding (or closing ) the part of the window that overlaps any FWH window does not get cleared till it is fully closed.
4) Important: I put an xbrowse or wbrowse in the window. During opening and closing animation, the window is totally black. Browse appears after the window is fully open and window gets black immediately before commencing the closing animation. I shall continue experimenting with on paint ownd:say, etc.
I am using opening activation as Mr. Antonio suggested. For closing I am using " VALID ( AnimateWindow( oWnd:hWnd, 200, nOr ( AW_HIDE, AW_VER_POSITVE ), .T. )". Mr. Antonio may suggest, with this usage is the window properly closed and released?.
1) Animation is not working with dialogs. Even with bStart.
2) Working with windows both while opening and closing. While opening, both AW_SLIDE and AW_ACTIVATE are giving the same effect. While closing we need to set flags to AW_HIDE. ( or'd with direction flag ofcourse).
3) Important: While hiding (or closing ) the part of the window that overlaps any FWH window does not get cleared till it is fully closed.
4) Important: I put an xbrowse or wbrowse in the window. During opening and closing animation, the window is totally black. Browse appears after the window is fully open and window gets black immediately before commencing the closing animation. I shall continue experimenting with on paint ownd:say, etc.
I am using opening activation as Mr. Antonio suggested. For closing I am using " VALID ( AnimateWindow( oWnd:hWnd, 200, nOr ( AW_HIDE, AW_VER_POSITVE ), .T. )". Mr. Antonio may suggest, with this usage is the window properly closed and released?.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
here is another solution with transparent or fading dialogs. Maybe it´s helpful or you
Code: Select all
#include "Fivewin.ch"
#define LWA_ALPHA 2
#define GWL_EXSTYLE -20
#define WS_EX_LAYERED 524288
FUNCTION MAIN()
LOCAL oDlg, nFactor := 210, btnmais, btnmenos, btnloops
DEFINE DIALOG oDlg;
TITLE "Transparent dialog" pixel from 0, 0 to 400, 400
@10, 10 SAY "This is a test" SIZE 30, 7 pixel
oDlg:bpainted := { || SETTRANSP( oDlg, nFactor ) }
@050, 10 button btnMais prompt "Mais Transparencia" ;
action TRANSPAR( oDlg, @nFactor, "+", btnmais ) size 70, 20 pixel
@050, 100 button btnMenos prompt "Menos Transparencia" ;
action TRANSPAR( oDlg, @nFactor, "-", btnmenos ) size 70, 20 pixel
@100, 50 button btnloops prompt "Alternando Transparencia" ;
action TRANSLOOP( oDlg, @nFactor ) size 70, 20 pixel
ACTIVATE DIALOG oDlg CENTER
RETURN NIL
STATIC FUNCTION SETTRANSP( oDlg, nFactor )
SETWINDOWLONG( oDlg:hWnd, GWL_EXSTYLE, ;
NOR( GETWINDOWLONG( oDlg:hWnd, ;
GWL_EXSTYLE ), WS_EX_LAYERED ) )
SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, , ;
nFactor, LWA_ALPHA )
RETURN NIL
static function TRANSPAR( oDlg, nFactor, Sinal, oBtn )
if Sinal = "+"
if nFactor < 10 ; nFactor := 260 ; endif
nFactor -= 5
else
if nFactor > 250 ; nFactor := 5 ; endif
nFactor += 5
endif
SetWindowText( oDlg:hWnd, "Transparent dialog. Transparencia: " + alltrim(str(nFactor)) )
SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, , nFactor, LWA_ALPHA )
sysrefresh()
return (nil)
static function TRANSLOOP( oDlg, nFactor, Sinal, oBtn )
local X
for X = 1 to 255
SetWindowText( oDlg:hWnd, "Transparent dialog. Transparencia: " + alltrim(str(x)) )
SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, , x, LWA_ALPHA )
next
for X = 255 to 1 step -1
SetWindowText( oDlg:hWnd, "Transparent dialog. Transparencia: " + alltrim(str(x)) )
SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, , x, LWA_ALPHA )
next
SetWindowText( oDlg:hWnd, "Transparent dialog. Transparencia: " + alltrim(str(nFactor)) )
SETLAYEREDWINDOWATTRIBUTES( oDlg:hWnd, , nFactor, LWA_ALPHA )
sysrefresh()
return NIL
DLL32 function SetLayeredWindowAttributes( hWnd As LONG, crKey As LONG,;
bAlpha As LONG, dwFlags As LONG ) AS LONG PASCAL ;
from "SetLayeredWindowAttributes" lib "user32.DLL"
kind regards
Stefan
Stefan
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Mr Antonio
I take your advice. Thanks
Mr. Stephan
You know this was not what I was looking for to start with.
But surely I am happier that you shared such a wonderful program with all of us. The effects are amazing and I thank you very much for it. Yes I would definitely use this code. May I ask if you already know any limitations about various windows versions? or should we test now?
I take your advice. Thanks
Mr. Stephan
You know this was not what I was looking for to start with.
But surely I am happier that you shared such a wonderful program with all of us. The effects are amazing and I thank you very much for it. Yes I would definitely use this code. May I ask if you already know any limitations about various windows versions? or should we test now?
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India