Testing Window-Api < AnimateWindow >

Testing Window-Api < AnimateWindow >

Postby ukoenig » Fri Dec 14, 2012 8:11 pm

Hello,

closing a window with a fade-out-effect, try this little function instead of a simple ownd:End()
As well I created some curtain-effects, closing dialogs / bars.

Image

Code: Select all  Expand view

// aRect3 := GetSysmetrics( 1 ) // Screen-Height
// aRect4 := GetSysmetrics( 0 ) // Screen-Width
// instead of oWnd:End() => WND_CLOSE(oWnd, aRect[4], aRect[3])

FUNCTION WND_CLOSE(oWnd, nWidth, nHeight)
LOCAL nMinusW := nWidth / 30, nMinusH := nHeight / 30
LOCAL nT := 0, nL := 0, nW := nWidth, nH :=  nHeight

I := 1
FOR I := 1 TO 20
    INKEY(0.01)
    nT := nT + nMinusH
    nL := nL + nMinusW
    nW := nW - ( 2 * nMinusW )
    nH := nH - ( 2 * nMinusH )
    oWnd:Move( nT, nL, nW, nH , .f. )  // Top, left, width, height
NEXT
oWnd:End()

RETURN NIL
 


Best Regards
Uwe :lol:
Last edited by ukoenig on Thu Jan 03, 2013 1:33 pm, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Closing Window with Zoom-effect ( blinding out )

Postby Silvio.Falconi » Sun Dec 16, 2012 7:58 pm

Sorry, can post a minimal sample to try ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7056
Joined: Thu Oct 18, 2012 7:17 pm

Re: Closing Window with fade-out-effect

Postby ukoenig » Sun Dec 16, 2012 8:43 pm

Silvio,
2 working samples : maximized and defined size and position

I just finished another nice effect :
a Buttonbar moves in and moves back, leaving the bar-area, like in Windows8.

Code: Select all  Expand view

#include "FiveWin.ch"

FUNCTION MAIN()
LOCAL oWnd, oBigFont, oSay1, oBrush

DEFINE FONT oBigFont NAME "Segoe UI" SIZE 0, -50
DEFINE BRUSH oBrush COLOR 128

DEFINE WINDOW oWnd  ;
STYLE nOr( WS_POPUP, WS_VISIBLE )

@ 50, 200 SAY oSay1 PROMPT "Modern UI Style" OF oWnd FONT oBigFont  PIXEL SIZE 400, 300
oSay1:lTransparent := .T.
oSay1:SetColor( 16443068 )

ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT oWnd:SetBrush( oBrush ) ;
ON CLICK WND_CLOSE(oWnd)

oBigfont:End()
oBrush:End()

RETURN NIL

// ------ SAMPLE 2 with defined Window-size and position -------------

#include "FiveWin.ch"

FUNCTION MAIN()
LOCAL oWnd, oBigFont, oSay1, oBrush

DEFINE FONT oBigFont NAME "Segoe UI" SIZE 0, -50
DEFINE BRUSH oBrush COLOR 128

DEFINE WINDOW oWnd FROM 100, 100 TO 500, 700 PIXEL ;
STYLE nOr( WS_POPUP, WS_VISIBLE )

@ 50, 200 SAY oSay1 PROMPT "Modern UI Style" OF oWnd FONT oBigFont  PIXEL SIZE 400, 300
oSay1:lTransparent := .T.
oSay1:SetColor( 16443068 )

ACTIVATE WINDOW oWnd ;
ON INIT oWnd:SetBrush( oBrush ) ;
ON CLICK WND_CLOSE(oWnd)

oBigfont:End()
oBrush:End()

RETURN NIL

// --------------- FADE OUT Effect --------------

FUNCTION WND_CLOSE(oWnd)
LOCAL nMinusW := oWnd:nWidth / 30, nMinusH := oWnd:nHeight / 30
LOCAL nT := oWnd:nTop, nL := oWnd:nLeft, nW := oWnd:nWidth, nH :=  oWnd:nHeight

I := 1
FOR I := 1 TO 20
    INKEY(0.01)
    nT := nT + nMinusH
    nL := nL + nMinusW
    nW := nW - ( 2 * nMinusW )
    nH := nH - ( 2 * nMinusH )
    oWnd:Move( nT, nL, nW, nH , .f. )  // Top, left, width, height
NEXT
oWnd:End()

RETURN NIL
 


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Closing Window with fade-out -effect

Postby fraxzi » Mon Dec 17, 2012 12:26 am

Dear Uwe,


Very nice!
Kind Regards,
Frances

Fivewin for xHarbour v18.07
xHarbour v1.2.3.x
BCC 7.3 + PellesC8 ( Resource Compiler only)
ADS 10.1 / MariaDB
Crystal Reports 8.5/9.23 DE
xMate v1.15
User avatar
fraxzi
 
Posts: 811
Joined: Tue May 06, 2008 4:28 am
Location: Philippines

Re: Closing Window with fade-out -effect

Postby Otto » Mon Dec 17, 2012 10:51 am

Hello Uwe,
I operate my Software through remote desktop.
I get this screen:

Image
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Closing Window with fade-out -effect

Postby ukoenig » Mon Dec 17, 2012 12:12 pm

Otto,

maybe there is still another solution.
The idea is, resizing a window or Dialog inside a FOR / NEXT
before the final < :end() > is called ( Fade-out )
Maybe it is possible, to define a optional END-effect inside the classes ?

Best Regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Closing Window with fade-out -effect

Postby James Bott » Sun Dec 23, 2012 12:40 am

Uwe,

There is a windows API call to do window animation. I found the code below in my archives. I know it works on XP but I don't know if it works on newer windows versions.

James

Code: Select all  Expand view
/*

It's possible to close Window and Dialog with Fade out or Fade in effect ?
How to ? What to do for Fw2.1c user ?

From: "Morris D'Andrea" <m_dandrea@cogeco.ca>
Subject: Re: Give me some idea...
Date: Wednesday, October 05, 2005 9:22 PM

Here is an attached example using the Animatewindow API call. used Fw2.1c
blinker 6 , tested under windows 2000 and 98. Various effects on a dialog
and window including fade, slide, from center, from top left , from top
right are in the example.

Morris

Oops forgot to mention you may want to play with the second parameter in the
api call in the example below it is set to 500 , you may want to increase
for faster systems or decrease it for slower ones ( makes the effect
smoother depending on CPU speed ) .

    AnimateWnd(gethwnd32(ownd:hwnd), 500, nor(AW_BLEND,AW_HIDE) )

Morris

*/







#include "fivewin.ch"
#define AW_HOR_POSITIVE   1 //Animates the window from left to right. This flag can be used with roll or slide animation.
#define AW_HOR_NEGATIVE   2 //Animates the window from right to left. This flag can be used with roll or slide animation.
#define AW_VER_POSITIVE   4 //Animates the window from top to bottom. This flag can be used with roll or slide animation.
#define AW_VER_NEGATIVE   8 //Animates the window from bottom to top. This flag can be used with roll or slide animation.
#define AW_CENTER        16 //Makes the window appear to collapse inward if AW_HIDE is used or expand outward if the AW_HIDE is not used.
#define AW_HIDE       65536 //Hides the window. By default, the window is shown
#define AW_ACTIVATE  131072 //Activates the window.
#define AW_SLIDE     262144 //Uses slide animation. By default, roll animation is used.
#define AW_BLEND     524288 //Uses a fade effect.This flag can be used only if hwnd is a top-level window.

static odlg
static ownd

function main()

    DEFINE WINDOW oWnd ;
      color "N/B*";
      TITLE "Window Animation Effects";
      MENU BUILDMENU()

 ACTIVATE WINDOW  ownd ON init size_it(ownd) ;
  valid close_wnd(ownd)

return(NIL)

function size_it(ownd)

     // Important if any part of the window is drawn
     // past the top of screen or the bottom of window
     // is beyond the taskbar the window hides first and
     // then the effect is applied dialogs seem to work fine
     // (tested with FW 2.1c)

   SetWindowPos( ownd:hWnd, 0,0, 0,;
                 getsysmetrics(0) ,;
                 getsysmetrics(1) - 29)


bringwindowtotop(gethwnd32(ownd:hwnd))
ownd:setfocus()

return(NIL)

FUNCTION BuildMenu()
   LOCAL oMenu

   MENU oMenu
      MENUITEM OemToAnsi( "&Test Effects..." )
      MENU
       MENUITEM "Top Right Down..."                                    ;
         MESSAGE "Click here to Exit";
            ACTION (toprightdown(ownd))
       MENUITEM "Top Left Down..."                                    ;
         MESSAGE "Click here to Exit";
            ACTION (topleftdown(ownd))
       MENUITEM "Fade ..."                                    ;
         MESSAGE "Click here to Exit";
            ACTION (Fade(ownd))
       MENUITEM "From Center..."                                    ;
         MESSAGE "Click here to Exit";
            ACTION (fromcenter(ownd))
       MENUITEM "Open Dialog..."                                    ;
         MESSAGE "Click here to Exit";
            ACTION (opendlg())
       MENUITEM "E&xit..."                                    ;
         MESSAGE "Click here to Exit";
            ACTION (ownd:end())
     ENDMENU

  ENDMENU



RETURN( oMenu )


function opendlg(ownd)


   local ctitle
   cTitle := "Dialog Fade"

   DEFINE DIALOG oDlg FROM 5,10 TO 24, 55 TITLE cTitle ;
      COLOR "N/W"
   @ 2, 7 BUTTON "&Top Right Down" OF oDlg SIZE 70, 12 ;
        ACTION toprightdown(odlg)
   @ 4, 7 BUTTON "&Top Left Down" OF oDlg SIZE 70, 12 ;
        ACTION topleftdown(odlg)
   @ 6, 7 BUTTON "&From Center" OF oDlg SIZE 70, 12 ;
        ACTION fromcenter(odlg)
   @ 8, 7 BUTTON "&Fade dialog" OF oDlg SIZE 70, 12 ;
        ACTION fade(odlg)


   ACTIVATE DIALOG oDlg CENTERED  ;
                on init bringwindowtotop(gethwnd32(odlg:hwnd)) ;
                 valid close_wnd(odlg)

return NIL


function topleftdown(thewnd)
   thewnd:hide()
   AnimateWnd( gethwnd32(thewnd:hwnd), 200, AW_VER_POSITIVE + AW_HOR_POSITIVE + AW_SLIDE)
   thewnd:setfocus()
return(NIL)

function toprightdown(thewnd)
   thewnd:hide()
   AnimateWnd( gethwnd32(thewnd:hwnd), 200, AW_VER_POSITIVE + AW_HOR_NEGATIVE + AW_SLIDE)
   thewnd:setfocus()
return(NIL)

function fromcenter(thewnd)
   thewnd:hide()
   AnimateWnd( gethwnd32(thewnd:hwnd), 200, AW_CENTER)
   thewnd:setfocus()
return(NIL)

function fade(thewnd)
   AnimateWnd( gethwnd32(thewnd:hwnd), 200, AW_BLEND + AW_HIDE)
   msginfo("Window Faded")
   thewnd:show()
   thewnd:setfocus()
return(NIL)

function close_wnd(ownd)
    AnimateWnd(gethwnd32(ownd:hwnd), 1000, nor(AW_BLEND,AW_HIDE) )
    do while iswindowvisible(ownd:hwnd)
    sysrefresh()
    enddo
return(.t.)

DLL32 Function AnimateWnd(hwnd As LONG, dwTime As LONG,dwFlags As LONG) As BOOL;
      PASCAL FROM "AnimateWindow" Lib "user32"
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Closing Window with fade-out -effect

Postby ukoenig » Sun Dec 23, 2012 1:50 pm

James,

thank You very much for the info.
Tested and still works with Windows8.
I will have a closer look and create a sample with different styles.

Merry Christmas and a Happy New Year to You and Your family

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Testing Window-Api < AnimateWindow >

Postby ukoenig » Thu Jan 03, 2013 1:16 pm

James,

I started to test the usage of the Win-Api.
It works with Windows8, but the results don't look very nice.
( There is a possible SLIDE- or ROLL- effect )
Parts are not shown during the different effects.
I will try to find another solution.


The original

Image

Sample fade out
( the different effects don't keep the original controls and only parts are still visible )

Image

Happy new Year
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Testing Window-Api < AnimateWindow >

Postby James Bott » Thu Jan 03, 2013 3:46 pm

Uwe,

Have you tested it with older versions of Windows? I wonder if the problem is because those are not standard Windows controls? I also wonder if a change to the paint methods of those controls would fix the problem.

I know I tested it with Windows XP and all the controls I used were working fine.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Testing Window-Api < AnimateWindow >

Postby nageswaragunupudi » Thu Jan 03, 2013 5:07 pm

I tested this windows API long time back. I was not very happy with the results, otherwise these would have been part of FWH natively long time back.
Regards

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 102 guests