Re: Desktop Alerts
Posted: Tue Mar 08, 2016 1:15 pm
Antonio,
Add popupmenu into btndown
Add DesktopAlerts Settings dialog
Two question
1. when I click on btndown it open the DesktopAlerts Settings dialog but when the ntimer is finished it close this dialog and the final user cannot insert his options
any solution ?
2. How I can to have an animation i explain you
When it is showed the dialogAlert from downs to up and when it is ended the dialog hide to down
Add popupmenu into btndown
Add DesktopAlerts Settings dialog
Two question
1. when I click on btndown it open the DesktopAlerts Settings dialog but when the ntimer is finished it close this dialog and the final user cannot insert his options
any solution ?
2. How I can to have an animation i explain you
When it is showed the dialogAlert from downs to up and when it is ended the dialog hide to down
Code: Select all | Expand
#include "FiveWin.ch"
#include "Slider.ch"
static nTransparency
static nlongTimer
//----------------------------------------------------------------------------//
function Main()
local oWnd
DEFINE WINDOW oWnd TITLE "Click me for a desktop notification"
ACTIVATE WINDOW oWnd ;
ON CLICK DesktopAlert( oWnd )
return nil
//----------------------------------------------------------------------------//
function DesktopAlert( oWnd )
local oDlg, oBrush, oFont
local hLogo := FWLogoBitMap()
local oBtnClose
local oBtnDown
local oFontBody
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 "A desktop 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
@ 0.6, oDlg:nWidth-175 BTNBMP oBtnClose FILENAME "C:\Work\fwh\bitmaps\16x16\cancel.bmp" ;
SIZE 10, 10 OF oDlg NOBORDER ACTION oDlg:End()
@ 0.6, oDlg:nWidth-185 BTNBMP oBtnDown FILENAME "C:\Work\fwh\bitmaps\16x16\darrow.bmp" ;
SIZE 10, 10 OF oDlg NOBORDER ACTION ShowPopup( oDlg )
oBtnClose:ltransparent:=.t.
oBtnDown:ltransparent:=.t.
ACTIVATE DIALOG oDlg ;
ON INIT ( SetTransparent( oDlg ), oDlg:Shadow(), BuildTimer( oDlg ) ) ;
ON CLICK oDlg:End() ;
ON PAINT DrawBitmap( hDC, hLogo, 9, 9 ) ;
VALID ( DeleteObject( hLogo ), .T. ) ;
NOWAIT
oBrush:End()
oFont:End()
oWnd:SetFocus()
return nil
//----------------------------------------------------------------------------//
function BuildTimer( oDlg )
local oTimer
local nStart := Seconds()
DEFAULT nlongTimer:= 5
oDlg:SetPos( ScreenHeight() - 80, ScreenWidth( 0 ) - 350 )
DEFINE TIMER oTimer OF oDlg ;
INTERVAL 10;
ACTION If( Seconds() - nStart > nlongTimer, oDlg:End(),)
ACTIVATE TIMER oTimer
return nil
//----------------------------------------------------------------------------//
#define GWL_EXSTYLE -20
#define WS_EX_LAYERED 524288
static function SetTransparent( oDlg )
DEFAULT nTransparency:= 180
SetWindowLong( oDlg:hWnd, GWL_EXSTYLE, nOr( GetWindowLong( oDlg:hWnd, GWL_EXSTYLE ), WS_EX_LAYERED ) )
SetLayeredWindowAttributes( oDlg:hWnd, 0, nTransparency, 2 )
return nil
//----------------------------------------------------------------------------//
static function DeskTopAlertSettings()
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 := 5
local nOptionTrans:= 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
//----------------------------------------------------------------------------//
function ShowPopup( oDlg )
local oPopSample
MENU oPopSample POPUP
MENUITEM "Your Option"
SEPARATOR
MENUITEM "Desktop Alert Settimgs" ACTION DeskTopAlertSettings()
ENDMENU
ACTIVATE POPUP oPopSample OF oDlg AT 100, 100
return nil