Page 1 of 1

screensavers en fivewin

PostPosted: Tue Sep 22, 2009 3:26 pm
by QAZWSX2K
saludos, necesito hacer un protector de pantalla con noticias para la empresa, y basandome en la idea que lei en este post http://forums.fivetechsupport.com/viewtopic.php?f=18&t=14125&p=72816&hilit=screensavers#p72816 y aunque he hecho algo mas rudimentario, si ven la web que comenta antonio no veo la manera de hacer algo parecido con fivewin, para comenzar les comentare los problemas que he encontrado a ver en que me pueden ayudar

- la ventana o dialogo no quedan siempre on top, si bien se activa como protector y aparece la ventana maximizada si le doy a la tecla de inicio pierde el foco, etc
- a la ventana o dialogo me veo obligado ponerle los iconos de salir, minimizar, etc para que pueda salir con esc, de lo contrario no sale con esc y al darle alf+f4 cierra la aplicacion pero permanece en memoria
- eso sin mencionar que la imagen debe ser bmp, y aunque puedo con freeimage ponerle con jpg no consigo que tome el tamaño del escritorio


saludos y gracias por su comentarios e ideas

Re: screensavers en fivewin

PostPosted: Wed Sep 23, 2009 1:16 pm
by QAZWSX2K
:arrow:

Re: screensavers en fivewin

PostPosted: Wed Sep 23, 2009 2:34 pm
by Daniel Garcia-Gil
Hola...

Por favor podrias colocar la rutina que usas, talvez podriamos ayudarte a lograr lo que quieres hacer y seria mas facil tener el punto de partida

Re: screensavers en fivewin

PostPosted: Wed Sep 23, 2009 5:32 pm
by Antonio Linares
Alex,

En samples\GetTime.prg tienes un ejemplo que tal vez pueda serte útil.

Re: screensavers en fivewin

PostPosted: Thu Sep 24, 2009 2:49 pm
by QAZWSX2K
Excelente con el ejemplo que me comento antonio pude darme cuenta de que estaba mal y en base a ese solucione el problema, gracias a ambos

Re: screensavers en fivewin

PostPosted: Thu Sep 24, 2009 3:55 pm
by Cgallegoa
El ejemplo FWH\Samples\GetTime.prg mejorado:

Code: Select all  Expand view

#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


Saludos,

Carlos Gallego