#include "fivewin.ch"
#include "Slider.ch"
STATIC nTransparency
STATIC c_path, c_path1
FUNCTION MAIN()
LOCAL oMain
LOCAL oTimer
LOCAL oButton
LOCAL oStr1
c_path := cFilePath(GetModuleFileName( GetInstance() ) )
c_path1 := c_Path + "IMAGES\"
DEFINE WINDOW oMain FROM 100 , 100 TO 500 , 500 PIXEL
DEFINE TIMER oTimer OF oMain INTERVAL 1000 ACTION ( Listen( oTimer,oMain ) )
// say not needed
@ 4 , 5 SAY oStr1 PROMPT "Create a log.txt file with some text inside" OF oMain
@ 5 , 5 SAY oStr1 PROMPT "Copy this file into the program dir" OF oMain
@ 6 , 5 SAY oStr1 PROMPT "The program sees this file and interact" OF oMain
@ 8 , 5 SAY oStr1 PROMPT "Activate the program 'HIDDEN' to work in the background" OF oMain
@ 9 , 5 SAY oStr1 PROMPT "This window is not needed anymore" OF oMain
@11 , 5 SAY oStr1 PROMPT "I use this sample to popup my phone and show customer data" OF oMain
// use the HIDDEN version if you want to start the program and HIDE, so it's working in the background
//ACTIVATE WINDOW oMain HIDDEN ON INIT ( OTimer:Activate() )
ACTIVATE WINDOW oMain ON INIT ( OTimer:Activate() )
RELEASE TIMER oTimer
RETURN NIL
FUNCTION Listen( oTimer,oMain )
LOCAL cFile := "log.txt"
LOCAL cString := ""
oTimer:deactivate()
IF FILE( cFile )
cString := MEMOREAD( cFile )
DeskAlert(cString,oMain,10) // 10 = seconds
// In my case there is a external CTI program that will erase the file.
// This DO/ENDDO can be erased than.
DO WHILE .T.
IF FERASE( cFile ) = 0
EXIT
ENDIF
sleep(1000)
ENDDO
ENDIF
oTimer:activate()
RETURN NIL
//----------------------------------------------------------------------------//
#define GWL_EXSTYLE -20
#define WS_EX_LAYERED 524288
//----------------------------------------------------------------------------//
FUNCTION DESKALERT( cString, oWnd, nlongTimer )
local oDlg, oBrush, oFont
local hLogo := FWLogoBitMap()
local oBtnClose
local oBtnDown
local oFontBody
local lEnd := .T.
local oString
DEFINE FONT oFont NAME "Verdana" BOLD
DEFINE FONT oFontBody NAME "Verdana" SIZE 0, -9
DEFINE BRUSH oBrush GRADIENT { { 1, nRgb( 221, 236, 253 ), nRgb( 95, 131, 179 ) } }
DEFINE DIALOG oDlg STYLE nOr( WS_POPUP, WS_BORDER ) ;
BRUSH oBrush SIZE 328, 73
@ 0.6, 6 SAY "Incoming Call notification" OF oDlg TRANSPARENT FONT oFont
//@ 1.2, 6 SAY "This a sample text area."+CRLF+"This a sample text area." OF oDlg TRANSPARENT FONT oFontBody SIZE 100,30
@ 1.2, 6 SAY oString VAR cString OF oDlg TRANSPARENT FONT oFontBody SIZE 100,30
@ 0.6, oDlg:nWidth-175 BTNBMP oBtnClose FILENAME c_path1 + "Exit1.bmp" ;
SIZE 10, 10 OF oDlg NOBORDER ACTION ( lEnd := .F., oDlg:End() )
@ 0.6, oDlg:nWidth-185 BTNBMP oBtnDown FILENAME c_path1 + "Drop.bmp" ;
SIZE 10, 10 OF oDlg NOBORDER ACTION ( nlongTimer := 0, ShowPopup( oDlg ) )
oBtnClose:ltransparent:=.t.
oBtnDown:ltransparent:=.t.
ACTIVATE DIALOG oDlg ;
ON INIT ( SetTransparent( oDlg ), oDlg:Shadow(), oDlg:Move( 70, 70, , , .T.) ) ;
ON CLICK oDlg:End() ;
ON PAINT DrawBitmap( hDC, hLogo, 15, 15 ) ;
VALID ( nlongTimer > 0, .T. ) ;
NOWAIT
IF nlongTimer > 0
SYSWAIT1(nlongTimer)
lEnd := .F.
oDlg:End()
ENDIF
DeleteObject( hLogo )
oBrush:End()
oFont:End()
oWnd:SetFocus()
RETURN lEnd
//-------------------------------------------
STATIC FUNCTION SETTRANSPARENT( oDlg )
DEFAULT nTransparency:= 230 // 180
SetWindowLong( oDlg:hWnd, GWL_EXSTYLE, nOr( GetWindowLong( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) )
SetLayeredWindowAttributes( oDlg:hWnd, 0, nTransparency, 2 )
RETURN NIL
//-------------------------------------------
FUNCTION SHOWPOPUP( oDlg, nlongTimer )
local oPopSample
MENU oPopSample POPUP
MENUITEM "Open Customer dialogs" action xbrowse("customer")
MENUITEM "Send message on the network" action msginfo("Some data send and viewed by desktopalert")
SEPARATOR
MENUITEM "Desktop Alert Settimgs" ACTION DeskTopAlertSettings(nlongTimer)
ENDMENU
ACTIVATE POPUP oPopSample OF oDlg AT 100, 100
RETURN NIL
//-------------------------------------------
FUNCTION SYSWAIT1( nLong )
local nSeconds
DEFAULT nLong := .1
nSeconds := Seconds() + nLong
WHILE Seconds() < nSeconds
SysRefresh()
END
RETURN NIL
//------------------------------------------
STATIC FUNCTION DESKTOPALERTSETTINGS(nlongTimer)
Local oDlgSettings
Local cText_Duration:="How long should the desktop alert appear ?"
local cText_transparency:="How transparency should the desktop be ?"
local oTrans,oDuration
local obtn[3]
local oGrp[2]
LOCAL oSay[2]
local nOptionDuration := 60 // 25
local nOptionTrans:= 50 //180
Local nBottom := 33
Local nRight := 62
* Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
* Local nHeight := nBottom * DLG_CHARPIX_H
DEFINE DIALOG oDlgSettings TITLE "DeskTopAlert Settings" SIZE 450, 300 ;
STYLE nOr( WS_THICKFRAME, WS_SYSMENU )
@ 0, 2 GROUP oGrp[1] PROMPT "Duration" OF oDlgSettings SIZE 200,40
@ 4, 2 GROUP oGrp[2] PROMPT "Transparency" OF oDlgSettings SIZE 200,40
@ 0.5, 6 SAY oSay[1] PROMPT cText_Duration OF oDlgSettings SIZE 120,10
@ 4.2, 6 SAY oSay[2] PROMPT cText_transparency OF oDlgSettings SIZE 120,10
@ 22, 45 SLIDER oDuration VAR nOptionDuration OF oDlgSettings ;
HORIZONTAL ;
RIGHT DIRECTION ;
RANGE -5, 60 ;
MARKS 11;
EXACT;
ON CHANGE nlongTimer := nOptionDuration ;
SIZE 102, 12 PIXEL
@ 78, 45 SLIDER oTrans VAR nOptionTrans OF oDlgSettings ;
HORIZONTAL ;
RIGHT DIRECTION ;
RANGE -10, 200 ;
MARKS 11;
EXACT;
ON CHANGE nTransparency := nOptionTrans ;
SIZE 102, 12 PIXEL
@ 113, 14 BUTTON obtn[1] PROMPT "&Preview" SIZE 45,12 OF oDlgSettings PIXEL
@ 113, 94 BUTTON obtn[2] PROMPT "&Ok" SIZE 45,12 OF oDlgSettings PIXEL ;
ACTION oDlgSettings:End(IDOK)
@ 113, 164 BUTTON obtn[3] PROMPT "&Cancel" SIZE 45,12 OF oDlgSettings PIXEL ;
ACTION oDlgSettings:End(IDCANCEL)
ACTIVATE DIALOG oDlgSettings CENTERED
IF oDlgSettings:nresult == IDOK
msginfo(nTransparency, nlongTimer )
Endif
RETURN NIL