#include "FiveWin.ch"
static nTime := 0
function Main()
local oDlg, oSay, oGet, cTest := Space( 10 )
DEFINE DIALOG oDlg TITLE "Test"
@ 0.5, 8 SAY oSay PROMPT "Elapsed time: " + AllTrim( Str( nTime ) ) + " secs."
@ 3, 7 GET oGet VAR cTest PASSWORD
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT BuildTimer( oDlg, oSay, oGet )
return nil
function BuildTimer( oDlg, oSay, oGet )
local oTmr
DEFINE TIMER oTmr OF oDlg ;
ACTION ( nTime++, oSay:Refresh(), If( nTime > 02, ScreenSaver(),)) INTERVAL 1000
ACTIVATE TIMER oTmr
oGet:bKeyDown = { | nKey | nTime := 0, nKey }
return nil
function ScreenSaver()
LOCAL oTimer2, oSay, oFont
static oDlg
nTime = 0
if oDlg == nil
ShowWindow( FindWindow( "Shell_TrayWnd", "" ), 0 ) // Taskbar
ShowWindow( FindWindow( "Button", "Start" ), 0 ) // Vista round button
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0,20 BOLD
DEFINE DIALOG oDlg STYLE WS_VISIBLE COLOR nRGB(255,255,255),nRGB(0,0,125) SIZE GetSysMetrics( 0 ), GetSysMetrics( 1 )
@ 10, 10 SAY oSay PROMPT "This is a screensaver" COLORS nRGB(255,255,255),nRGB(0,0,125) FONT oFont
oDlg:bKeyDown = { || oDlg:End() }
ACTIVATE DIALOG oDlg ;
ON INIT (BuildTimer2(oDlg, oSay));
ON CLICK oDlg:End()
ShowWindow( FindWindow( "Shell_TrayWnd", "" ), 1 )
ShowWindow( FindWindow( "Button", "Start" ), 1 )
oDlg = nil
nTime = 0
endif
return nil
function BuildTimer2( oDlg, oSay )
local oTmr
DEFINE TIMER oTmr OF oDlg ;
ACTION ( MoveSay(oDlg,oSay) ) INTERVAL 1000
ACTIVATE TIMER oTmr
return nil
Procedure MoveSay(oDlg,oSay)
local nHeightScr := 768 - 30
local nWidthScr := 1024 - 54
local nRow := nRandom(nHeightScr)
local nCol := nRandom(nWidthScr)
local nColorR := nRandom(255)
local nColorG := nRandom(255)
local nColorB := nRandom(255)
local nTextWidth := GetTextWidth(oSay:hDC,"This is a screensaver",oSay:oFont)
local lFlg1 := .F. , lFlg2 := .F. , lFlg3 := .F.
nRow := iif(nRow==0,1,nRow)
nCol := iif(nCol==0,1,nCol)
nCol := iif(nCol > (nWidthScr-nTextWidth),nWidthScr-nTextWidth,nCol)
lFlg1 := nColorR >= 0 .AND. nColorR <= 50 // 33
lflg2 := nColorG >= 0 .AND. nColorG <= 50 // 49
lFlg3 := nColorB >= 75 .AND. nColorB <= 175 // 132
if lFlg1 .AND. lFlg2 .AND. lFlg3
nColorR += 50
nColorG += 50
nColorB += 50
endif
oSay:Hide()
oSay:Move(nRow,nCol,,.T.)
oSay:SetColor( nRGB(nColorR,nColorG,nColorB) , nRGB(0,0,125) )
oSay:Show()
Return