Jump to content
Fivewin Brasil

Flash na Janela(window)


kapiaba

Recommended Posts


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


Link to comment
Share on other sites

TONE()


REQUEST HB_GT_GUI_DEFAULT



Beto,


Outras ideias...




#include "Fivewin.ch"

REQUEST HB_GT_GUI_DEFAULT

FUNCTION MAIN()

LOCAL oWnd

DEFINE WINDOW oWnd FROM 100 , 100 TO 500 , 500 PIXEL

oWnd:bResized = { || IIF(IsIconic( oWnd ), tone(1000,1), tone(100,1) ) }

ACTIVATE WINDOW oWnd ICONIZED

RETURN NIL



#include "fivewin.ch"

function Main()

local oWnd

DEFINE WINDOW oWnd
ACTIVATE WINDOW oWnd HIDDEN ON INIT ( MakeDialog(), oWnd:End() )

return nil

static function MakeDialog

local oDlg

DEFINE DIALOG oDlg

oDlg:nStyle += (WS_MINIMIZEBOX + WS_MAXIMIZEBOX)

ACTIVATE DIALOG oDlg CENTERED

return nil


Probably this is the solution:

Many thanks



#include "Fivewin.ch"

STATIC oDlg
STATIC oWnd

REQUEST HB_GT_GUI_DEFAULT

FUNCTION MAIN()

DEFINE WINDOW oWnd FROM 1000 , 1000 TO 1000 , 1000

oWnd:bResized = { || resize_wnd( ) }

ACTIVATE WINDOW oWnd ICONIZED ON INIT dialogo( )

RETURN NIL

FUNCTION DIALOGO( )

DEFINE DIALOG oDlg;
STYLE NOR( WS_POPUP, WS_VISIBLE, WS_CAPTION, WS_THICKFRAME, WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX );
TITLE "This is a test"

oDlg:bResized = { || resize_dlg( ) }

ACTIVATE DIALOG oDlg CENTER

IF oDlg:nresult = IDOK
oWnd:Iconize()
ELSE
oWnd:end()
ENDIF

RETURN NIL

FUNCTION RESIZE_DLG()

oDlg:end( IDOK )

RETURN NIL

FUNCTION RESIZE_WND()

IF .NOT. IsIconic( oWnd:hWnd )

dialogo()

ENDIF

RETURN NIL


Link to comment
Share on other sites

Beto, mais sugestoes...



/*
SHOWTASKBAR() // habilita
HIDETASKBAR() // desabilita
TIRA_X() // DESABILITA O X da janela
PISCA_EXE() // VAI PISCAR O SEU EXE NA BARRA
*/

#pragma BEGINDUMP

#include "windows.h"
#include "shlobj.h"
#include "hbapi.h"
#include "math.h"
#include "hbvm.h"
#include "hbstack.h"
#include "hbapiitm.h"
#include "hbapigt.h"

/*
HB_FUNC ( SHOWTASKBAR ) //Habilita o botao INICIAR
{
HWND hWnd = FindWindow("Shell_TrayWnd", "");

ShowWindow( hWnd, 1 );
}
*/

HB_FUNC ( HIDETASKBAR ) //Desabilita o botao Iniciar
{
HWND hWnd = FindWindow("Shell_TrayWnd", "");

ShowWindow( hWnd, 0 );
}

HB_FUNC ( PISCA_EXE ) // VAI PISCAR O SEU EXE NA BARRA
{
HWND Handle = GetForegroundWindow();

FlashWindow(Handle,TRUE); // VAI PISCAR O SEU EXE NA BARRA

Sleep(300); // TEMPO DE ESPERA
}

HB_FUNC ( TIRA_X ) // DESABILITA O X da janela

{
HMENU MenuH = GetSystemMenu(GetForegroundWindow(),FALSE);

EnableMenuItem(MenuH,SC_CLOSE,MF_GRAYED);
}

HB_FUNC ( VOLTA_X ) // HABILITA O X da janela

{
HMENU MenuH = GetSystemMenu(GetForegroundWindow(),TRUE);

EnableMenuItem(MenuH,SC_CLOSE,MF_GRAYED);
}

#pragma ENDDUMP


Link to comment
Share on other sites

Beto, mais sugestoes...
/*
SHOWTASKBAR()  // habilita
HIDETASKBAR()  // desabilita
TIRA_X()       // DESABILITA O X da janela
PISCA_EXE()    // VAI PISCAR O SEU EXE NA BARRA
*/
 
#pragma BEGINDUMP
 
#include "windows.h"
#include "shlobj.h"
#include "hbapi.h"
#include "math.h"
#include "hbvm.h"
#include "hbstack.h"
#include "hbapiitm.h"
#include "hbapigt.h"
 
/*
HB_FUNC ( SHOWTASKBAR ) //Habilita o botao INICIAR
{
HWND hWnd = FindWindow("Shell_TrayWnd", "");
 
ShowWindow( hWnd, 1 );
}
*/
 
HB_FUNC ( HIDETASKBAR ) //Desabilita o botao Iniciar
{
HWND hWnd = FindWindow("Shell_TrayWnd", "");
 
ShowWindow( hWnd, 0 );
}
 
HB_FUNC ( PISCA_EXE ) // VAI PISCAR O SEU EXE NA BARRA
{
HWND Handle = GetForegroundWindow();
 
FlashWindow(Handle,TRUE); // VAI PISCAR O SEU EXE NA BARRA
 
Sleep(300); // TEMPO DE ESPERA
}
 
HB_FUNC ( TIRA_X ) // DESABILITA O X da janela
 
{
HMENU MenuH = GetSystemMenu(GetForegroundWindow(),FALSE);
 
EnableMenuItem(MenuH,SC_CLOSE,MF_GRAYED);
}
 
HB_FUNC ( VOLTA_X ) // HABILITA O X da janela
 
{
HMENU MenuH = GetSystemMenu(GetForegroundWindow(),TRUE);
 
EnableMenuItem(MenuH,SC_CLOSE,MF_GRAYED);
}
 
#pragma ENDDUMP

João, boa noite.

Testei a função pisca_exe, mas ela funciona da seguinte forma:

Tenho 5 programas abertos na minha barra de tarefa.

Se o meu sistema estiver minimizado, estou trabalhando em outro aplicativo, quando o timer faz a chamada para o pisca_exe, não pisca meu programa, e sim o aplicativo que estou trabalhando.

Entendeu?

Preciso que pisque o meu programa, assim que o usuario receber uma mensagem e ele não estiver no sistema, hoje, se o sistema estiver minimizado, ele maximiza automaticamente quando recebe a mensagem, além de maximizar, gostaria de chamar a atenção, pq as vezes ele não está no computador, mas se passa na frente, ele vai saber que tem mensage.

Vlw.

Beto.

Link to comment
Share on other sites


// Programa Pisca Minimizado: FLASH3.PRG - 18/09/2015 kmt_karinha@pop.com.br

#include "fivewin.ch"

static ownd, omsgbar, oTimer

function main()

DEFINE WINDOW oWnd TITLE "Minimize Para Entender." ;
FROM 5, 5 TO 24, 64

DEFINE MSGBAR OMSGBAR OF OWND NOINSET

ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT( oTimer := FlashWndTimer( oWnd ), { | | IsIconic( oWnd:hWnd ) } )

oTimer:DeActivate()


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"


Link to comment
Share on other sites

oopps, desculpe a minha falha, foi a velocidade dos dedos...




// Programa Pisca Minimizado: FLASH3.PRG - 18/09/2015 kmt_karinha@pop.com.br

#include "fivewin.ch"

#Define SH_SHOWNORMAL 1 // Mostra o Estilo do Gerenciandor do Windows
#Define SW_SHOWMINIMIZED

#Define WM_SYSCOMMAND 274 // &H112
#Define SC_TASKLIST 61744 // &HF130
#Define SC_SCREENSAVE 61760 // &HF140
#Define SW_HIDE 0 // &H0
#Define SW_SHOWNA 8 // &H8
#Define SW_SHOW 5 // &H5
#Define SW_SHOWNORMAL 1
#Define SW_NORMAL 1
#Define SW_MAXIMIZE 3
#Define SW_MINIMIZE 6
#Define SW_RESTORE 9
#Define SC_MONITORPOWER 61808 // &HF170 Gracias a Ramon Ramirez por la info
#Define SM_CLEANBOOT 67

static ownd, omsgbar, oTimer

function main()

LOCAL oTimer

DEFINE WINDOW oWnd TITLE "Beto: Minimize Para Entender" ;
FROM 5, 5 TO 24, 64

DEFINE MSGBAR OMSGBAR OF OWND NOINSET

ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT ( oTimer := FlashWndTimer( oWnd,, { | | IsIconic( oWnd:hWnd ) } ) )

oTimer:DeActivate()

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"

// FIM DO PROGRAMA By Joao Santos

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...