Emerging Window - Simple Example

Emerging Window - Simple Example

Postby MGA » Sat May 30, 2015 4:33 pm

Example of an emerging window. To be used as message in our system.

Code: Select all  Expand view


#include "fivewin.ch"

#define AW_VER_NEGATIVE        0x00000008  // animate window
#define AW_SLIDE               0x00040000  // animate window

static owndidc, ownd, omsgbar

function main()

   oWndIdc := NIL

   DEFINE WINDOW oWnd TITLE "Message Test - Press F3" ;
      FROM 5, 5 TO 24, 64

   DEFINE MSGBAR OMSGBAR OF OWND NOINSET

   oWnd:bKeyDown := {|nKey| IF(nKey==VK_F3,FwhMsgIDC( 'Message test'),)}
   ACTIVATE WINDOW oWnd maximized

return nil

/***************************************************************************************************/
procedure FwhMsgIDC( cMsg )

   local oSay, oFontIDC, nPos, nCol, otimer
   local nPosAux := 250
   local nColAux := 245

   Default cMsg := ''

   if oWndIdc != nil
      oWndIdc:End()
      oWndIdc := nil
      syswait(0.2)
   endif

   nPos := ownd:omsgbar:nWidth-nPosAux
   nCol := ownd:omsgbar:ntop-nColAux

   define font ofontidc name "Lucida Console" size -8,16 bold

   define window owndidc title "Message" from nCol, nPos to ( nCol+nColAux ), ( nPos+nPosAux ) pixel nominimize nomaximize color CLR_BLACK, RGB(126,192,238) of oWnd

   @ 00,-10 say osay var cMsg of owndidc center font ofontidc size 250,245 pixel

   AnimateWindow( owndidc:hwnd,400, nor( AW_SLIDE, AW_VER_NEGATIVE ) )

   SetWindowPos( owndidc:hwnd, -1, 0, 0, 0, 0, 3 )

   activate window owndidc on init( oTimer := FlashWndTimer( owndidc ),;
                                    owndidc:Refresh(), SysRefresh() );
                            valid( owndidc := nil,;
                                   hb_gcall( .t. ),;
                                   ofontidc:End(),;
                                   oTimer:DeActivate(),;
                                    .t. ) ;
                            on resize( oWndIdc:move(nCol,nPos),;
                                       oWndidc:nWidth  := nPosAux,;
                                       oWndidc:nHeight := nColAux,;
                                       oWndIdc:Refresh(),;
                                       SysRefresh() )
return

/********************************************************/
FUNCTION FlashWndTimer( ohWnd, nDelay, bWhen )
   local oTimer

   DEFAULT  nDelay  := 2000
   DEFAULT  bWhen   := { || .T. }

   DEFINE TIMER oTimer INTERVAL nDelay ACTION (Flashing( ohWnd, bWhen ))
   ACTIVATE TIMER oTimer

RETURN oTimer

/********************************************************/
STATIC FUNCTION Flashing( ohWnd, bWhen )
   static nStatus := 1
   local hWnd

   hWnd := iif( ValType(ohWnd) != "O", ohWnd, ohWnd:hWnd )

   if Eval( bWhen, hWnd )
      FlashWnd( hWnd, (nStatus := iif( nStatus == 1, 0, 1 )) )
   endif

RETURN .T.

DLL32 STATIC FUNCTION FlashWnd( hWnd AS LONG, nInvert AS LONG ) AS LONG PASCAL FROM "FlashWindow" LIB "User32.dll"
DLL32 FUNCTION AnimateWindow( hWnd AS LONG, nTime AS LONG, nFlags AS LONG ) AS BOOL PASCAL LIB "user32.dll"


 


:)
ubiratanmga@gmail.com

FWH18.02
FWPPC
Harbour/xHarbour
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1234
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Emerging Window - Simple Example

Postby Silvio.Falconi » Sat May 30, 2015 5:08 pm

nice
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: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Emerging Window - Simple Example

Postby vilian » Mon Jun 01, 2015 1:21 am

Very good ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: Emerging Window - Simple Example

Postby fafi » Mon Jun 01, 2015 10:14 pm

animate on exit
Code: Select all  Expand view


#include "fivewin.ch"

#define AW_VER_NEGATIVE        0x00000008  // animate window
#define AW_SLIDE               0x00040000  // animate window

#define AW_VER_POSITIVE  0x00000004
#define AW_BLEND 0x00080000

#define AW_HOR_NEGATIVE 0x00000002
#define AW_HOR_POSITIVE 0x00000001

#define AW_HIDE 0x00010000



static owndidc, ownd, omsgbar

function main()

   oWndIdc := NIL

   DEFINE WINDOW oWnd TITLE "Message Test - Press F3" ;
      FROM 5, 5 TO 24, 64

   DEFINE MSGBAR OMSGBAR OF OWND NOINSET

   oWnd:bKeyDown := {|nKey| IF(nKey==VK_F3,FwhMsgIDC( 'Message test'),)}
   ACTIVATE WINDOW oWnd maximized

return nil

/***************************************************************************************************/
procedure FwhMsgIDC( cMsg )

   local oSay, oFontIDC, nPos, nCol, otimer
   local nPosAux := 250
   local nColAux := 245

   Default cMsg := ''

   if oWndIdc != nil
      oWndIdc:End()
      oWndIdc := nil
      syswait(0.2)
   endif

   nPos := ownd:omsgbar:nWidth-nPosAux
   nCol := ownd:omsgbar:ntop-nColAux

   define font ofontidc name "Lucida Console" size -8,16 bold

   define window owndidc title "Message" from nCol, nPos to ( nCol+nColAux ), ( nPos+nPosAux ) pixel nominimize nomaximize color CLR_BLACK, RGB(126,192,238) of oWnd

   @ 00,-10 say osay var cMsg of owndidc center font ofontidc size 250,245 pixel

   //AnimateWindow( owndidc:hwnd,400, nor( AW_SLIDE, AW_VER_NEGATIVE ) )

   //AnimateWindow( owndidc:hwnd,400, nor( AW_SLIDE, AW_HOR_NEGATIVE ) )
   
   //AnimateWindow( owndidc:hwnd,400, nor( AW_SLIDE, AW_HOR_POSITIVE ) )
   
   AnimateWindow( owndidc:hwnd,400, nor( AW_HOR_NEGATIVE ) )
   
   
   

   SetWindowPos( owndidc:hwnd, -1, 0, 0, 0, 0, 3 )
/*
   activate window owndidc on init( oTimer := FlashWndTimer( owndidc ),;
                                    owndidc:Refresh(), SysRefresh() );
                            valid( Keluar(),owndidc := nil,;
                                   hb_gcall( .t. ),;
                                   ofontidc:End(),;
                                   oTimer:DeActivate(),;
                                    .t. ) ;
                            on resize( oWndIdc:move(nCol,nPos),;
                                       oWndidc:nWidth  := nPosAux,;
                                       oWndidc:nHeight := nColAux,;
                                       oWndIdc:Refresh(),;
                                       SysRefresh() )
*/


   activate window owndidc on init( oTimer := FlashWndTimer( owndidc ),;
                                    owndidc:Refresh(), ;
                                    oWndIdc:move(nCol,nPos),;
                                       oWndidc:nWidth  := nPosAux,;
                                       oWndidc:nHeight := nColAux,;
                                       oWndIdc:Refresh(),;
                                    SysRefresh() );
                            valid( Keluar(),owndidc := nil,;
                                   hb_gcall( .t. ),;
                                   ofontidc:End(),;
                                   oTimer:DeActivate(),;
                                    .t. )
                           
                                                                             
return

function Keluar()

aRect :=  GetClientRect(oWndIdc:hwnd)
nWidth := oWndidc:nWidth  
       
for i := 1 to aRect[3]

       oWndidc:nWidth  := nWidth
       nWidth := nWidth - i
             oWndIdc:Refresh()
             SysRefresh()
                                       
next

return nil

/********************************************************/
FUNCTION FlashWndTimer( ohWnd, nDelay, bWhen )
   local oTimer

   DEFAULT  nDelay  := 2000
   DEFAULT  bWhen   := { || .T. }

   DEFINE TIMER oTimer INTERVAL nDelay ACTION (Flashing( ohWnd, bWhen ))
   ACTIVATE TIMER oTimer

RETURN oTimer

/********************************************************/
STATIC FUNCTION Flashing( ohWnd, bWhen )
   static nStatus := 1
   local hWnd

   hWnd := iif( ValType(ohWnd) != "O", ohWnd, ohWnd:hWnd )

   if Eval( bWhen, hWnd )
      FlashWnd( hWnd, (nStatus := iif( nStatus == 1, 0, 1 )) )
   endif

RETURN .T.

DLL32 STATIC FUNCTION FlashWnd( hWnd AS LONG, nInvert AS LONG ) AS LONG PASCAL FROM "FlashWindow" LIB "User32.dll"
DLL32 FUNCTION AnimateWindow( hWnd AS LONG, nTime AS LONG, nFlags AS LONG ) AS BOOL PASCAL LIB "user32.dll"


/*
 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.
*/


 


regards
fafi
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: Emerging Window - Simple Example

Postby MGA » Tue Jun 02, 2015 2:12 am

fafi thanks!
ubiratanmga@gmail.com

FWH18.02
FWPPC
Harbour/xHarbour
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1234
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: Emerging Window - Simple Example

Postby Antonio Linares » Tue Jun 02, 2015 9:15 am

thanks for sharing it :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 79 guests

cron