// Programa para poner peque¤as notas en la pantalla
/*
/*
File Name : NOTAS.PRG Brainware Notes
Description:
It demonstrates the use of floating windows allways
on top. Very useful to keep anotations post-it kind
in your desktop.
If you put it on the Start group will mantain
pending things allways at your sight.
Demonstrates the power of Fivewin and its ease of use.
I provide this file to thank you all for the tips
downloaded from CServe in these years!
Comments are welcome.
Author : Fernando Chapa 104164,1417 & 75162,3247
Eduardo Valero
Brainware, S.C.
We are Brainware!
Date : 06/20/96
: Needs Fivewin 1.9 to compile
*/
#Include "FiveWin.ch"
Static oGet1, oGet2, oGet3, oBut
Function Main()
/*
Main floating window
*/
If !File("notas.dbf") .or. !File("notas.dll")
return nil
Endif
mxnotas:={}
mover=.t.
mcual=""
mnuevo=.t.
Set Resources to "notas.dll"
Use notas
pack
index on numero to notas.ntx
Set Dele On
Define window Notas from 0,3 to 1.3,31 STYLE WS_POPUP
@ 0,0 BITMAP resource "bwnotas" NOBORDER OF Notas PIXEL SIZE 64,21 ON LEFT CLICK Click2() ;
ON RIGHT CLICK Acerca()
@ 0, 8 BITMAP resource "nueva" of Notas ON LEFT CLICK Nueva()
@ 0, 13 BITMAP resource "mostrar" of Notas ON LEFT CLICK Act2()
@ 0, 18 BITMAP resource "ocultar" of Notas ON LEFT CLICK Quitar()
@ 0, 23 BITMAP resource "salir" of Notas ON LEFT CLICK Termina()
Activate Window Notas On Init (Act1(),SysRefresh(), Act2()) Valid Salir()
Set Resources to
Return nil
Function Salir()
Set Resources to
Close data
Return .t.
Func Termina()
Quitar()
Notas:End()
Quit
Return nil
Func Act1()
SetWindowPos(Notas:hWnd,-1,0,0,0,0,3)
Return nil
Func Nueva()
Go Bottom
xnum=numero+1
Append Blank
Replace numero with xnum, renglon with 200
mcual=Alltrim(Str(xnum))
Public ownd&mcual
Define Window ownd&mcual from renglon/16,columna/8 to renglon/16+6,columna/8+20 Color CLR_BLACK,CLR_YELLOW STYLE nOr(WS_POPUP,WS_BORDER) of Notas
ownd&mcual:Cargo:=mcual
ownd&mcual:bLClicked := { || Editar(ownd&mcual) }
Aadd(mxnotas,Strzero(val(mcual),4))
Activate Window oWnd&mcual on init Activa(ownd&mcual)
Return nil
Func Act2()
Quitar()
mnuevo=.f.
Go Top
Do while !Eof()
mcual=Alltrim(Str(numero))
Public ownd&mcual
Define Window ownd&mcual from renglon/16,columna/8 to renglon/16+6,columna/8+20 Color CLR_BLACK,CLR_YELLOW STYLE nOr(WS_POPUP,WS_BORDER) of Notas
ownd&mcual:Cargo:=mcual
ownd&mcual:bLClicked := { || Editar(ownd&mcual) }
Aadd(mxnotas,Strzero(val(mcual),4))
Activate Window oWnd&mcual on init Activa(ownd&mcual)
Skip
Enddo
Return nil
Func Quitar()
For i=1 to len(mxnotas)
mcual=Alltrim(str(val(mxnotas[i])))
ownd&mcual:End()
Next
mxnotas:={}
Return nil
Func Editar(xvent)
/*
Text edition
*/
If !mover
return nil
Endif
Public xr1, xr2, xr3
Seek Val(xvent:Cargo)
mcargo:=xvent:Cargo
If Found()
mover=.f.
xr1:=R1
xr2:=R2
xr3:=R3
@ 2.0, .5 GET oGet1 VAR xr1 of xvent SIZE 150,22
@ 3.6, .5 GET oGet2 VAR xr2 of xvent SIZE 150,22
@ 5.2, .5 GET oGet3 VAR xr3 of xvent SIZE 150,22
@ 0.5, 13 BUTTON oBut PROMPT "Ok" of xvent Action (Teredita(xvent))
Endif
Return nil
Func Teredita(yvent)
Replace R1 with xr1, R2 with xr2, R3 with xr3
mcargo=yvent:Cargo
oGet1:End()
oGet2:End()
oGet3:End()
oBut:End()
mover=.t.
mTexto(yvent)
Return nil
Func Activa(xvent)
xcargo=xvent:Cargo
@ 0,0 BITMAP resource "esquina" NOBORDER OF xvent PIXEL SIZE 80,21 ;
ON LEFT CLICK Click(xvent)
@ 5,140 BITMAP resource "quitar" NOBORDER OF xvent PIXEL SIZE 15,15 ;
ON LEFT CLICK Fin(xvent)
SetWindowPos(xvent:hwnd,-1,0,0,0,0,3)
mTexto(xvent)
Return nil
Func Click(yvent)
If !mover
return nil
Endif
Do while GetKeyState(VK_LBUTTON)
punto:=GetCursorpos()
MoveWindow( yvent:hWnd, punto[1],punto[2], 160,96,.t. )
Sysrefresh()
If !GetKeyState(VK_LBUTTON)
Exit
Endif
Enddo
punto:=GetCursorpos()
seek Val(yvent:Cargo)
If Found()
Replace renglon with punto[1], columna with punto[2]
Endif
mTexto(yvent)
Return nil
Func Click2()
Do while GetKeyState(VK_LBUTTON)
punto:=GetCursorpos()
MoveWindow( Notas:hWnd, punto[1],punto[2], 225,21,.t. )
Sysrefresh()
If !GetKeyState(VK_LBUTTON)
Exit
Endif
Enddo
Return nil
Func Fin(yvent)
If mover
mcual:=yvent:Cargo
Seek Val(mcual)
If Found()
If MsgYesNo(OemToAnsi("¨Desea eliminar esta nota?"),"BW Notas")
Delete
yvent:End()
x=Ascan(mxnotas,StrZero(Val(mcual)))
If x>0
y=len(mxnotas)
Adel(mxnotas,x)
Asize(mxnotas,y-1)
Endif
Go Top
Endif
Endif
Endif
Return nil
Func mTexto(zvent)
mzcual:=zvent:Cargo
Seek val(zvent:Cargo)
If Len(Alltrim(r1))=0 .and. Len(Alltrim(r2))=0 .and. Len(Alltrim(r3))=0
@ 2,1 SAY oSay1&mzcual PROMPT "Nota:"+zvent:Cargo of zvent
Else
@ 2,.5 SAY oSay1&mzcual PROMPT R1 of zvent SIZE 150,22
@ 3.6,.5 SAY oSay2&mzcual PROMPT R2 of zvent SIZE 150,22
@ 5.2,.5 SAY oSay3&mzcual PROMPT R3 of zvent SIZE 150,22
Endif
return nil
Func Acerca()
MsgInfo("By Fernando Chapa & Eduardo Valero","BW Notes")
Return nil