Animation of Windows

Animation of Windows

Postby nageswaragunupudi » Sun Nov 04, 2007 3:28 am

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?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Sun Nov 04, 2007 7:03 pm

Code: Select all  Expand view
#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"
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Mon Nov 05, 2007 5:03 am

Mr Antonio

Thanks. It is working. But I dont know why is not working with a Dialog. Why shd not dialog behave like window?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Mon Nov 05, 2007 7:48 am

NageswaraRao,

The dialog hWnd is not valid until the ACTIVATE of the dialog

You may use oDlg:bStart = { || ... }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Mon Nov 05, 2007 8:38 am

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?.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Mon Nov 05, 2007 8:49 am

> with this usage is the window properly closed and released?

yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby nageswaragunupudi » Mon Nov 05, 2007 8:50 am

ownd:bpainted does not work during animation. colors of window also do not show up during animations.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby Antonio Linares » Mon Nov 05, 2007 8:55 am

NageswaraRao,

Yes, I have noticed that too.

I would not recommend to use AnimateWindow() as it does not uses FWH windows procedure, but the standard (default) one
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42079
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby StefanHaupt » Mon Nov 05, 2007 9:12 am

here is another solution with transparent or fading dialogs. Maybe it´s helpful or you

Code: Select all  Expand view
#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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby nageswaragunupudi » Mon Nov 05, 2007 9:53 am

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?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Postby StefanHaupt » Tue Nov 06, 2007 9:13 am

NageswaraRao,

the sample is working with XP and Vista. Not tested with W98.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Postby RAMESHBABU » Tue Nov 06, 2007 3:29 pm

the sample is working with XP and Vista. Not tested with W98.


Not working in Win98!

- Ramesh Babu P
User avatar
RAMESHBABU
 
Posts: 624
Joined: Fri Oct 21, 2005 5:54 am
Location: Secunderabad (T.S), India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 58 guests