FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Luz en la caja del get
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Luz en la caja del get
Posted: Fri Nov 07, 2014 05:49 PM
Bonito efecto de luz para el rect de la caja del get...
¿ Como se podria hacer ?
Posts: 537
Joined: Mon Jan 16, 2006 03:42 PM
Re: Luz en la caja del get
Posted: Thu Nov 13, 2014 03:12 PM

Amigo aun no hay respuesta,

saludos

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Luz en la caja del get
Posted: Thu Nov 13, 2014 04:14 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Luz en la caja del get
Posted: Thu Nov 13, 2014 04:24 PM

Karinha,

Falta la luz :D . Es decir... falta el efecto de luz. El enlace no lo tiene, solo tiene un Roundrect()

jbrita, ya se anima la cosa... a ver a ver...

Saludos

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Luz en la caja del get
Posted: Thu Nov 13, 2014 10:11 PM

Podriamos dibujar un degradado en cada lado (arriba, izquierda, abajo, derecha). Tenemos una función para eso.

Pero en las esquinas no nos serviría.

Podriamos dibujar un RoundRect() e ir variando las coordenadas y el color de pintado, asi podría funcionar :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Luz en la caja del get
Posted: Thu Nov 13, 2014 10:59 PM
Debería poderse hacer asi pero de momento no consigo que funcione correctamente:

Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oDlg, cTest := Space( 20 ), oGet

   DEFINE DIALOG oDlg 

   @ 2, 3 GET oGet VAR cTest OF oDlg SIZE 100, 13

   oGet:bPainted = { || LightBorder( oGet ) }

   ACTIVATE DIALOG oDlg CENTERED

return nil

function LightBorder( oGet )

   local hDC := oGet:oWnd:GetDC()
   local hBrush, hOldBrush, n
   local aTopLeft, aBottomRight
   local oPen

   for n = 1 to 10
      SelectObject( hDC, oPen := TPen():New( ,, nRGB( n ^ 2, n ^ 2, 200 ) ):hPen )

      aTopLeft = ClientToScreen( oGet:hWnd, { oGet:nTop, oGet:nLeft } )
      aTopLeft = ScreenToClient( oGet:oWnd:hWnd, aTopLeft )
      
      aBottomRight = ClientToScreen( oGet:hWnd, { oGet:nBottom, oGet:nRight } )
      aBottomRight = ScreenToClient( oGet:oWnd:hWnd, aBottomRight )

      SetBkMode( hDC , 1 )
      Rectangle( hDC, aTopLeft[ 2 ] - 2 - n,;
                      aTopLeft[ 1 ] - 2 - n,;
                      aBottomRight[ 1 ] + 2 + n,;
                      aBottomRight[ 2 ] + 2 + n )
      oPen:End()
   next   

   oGet:oWnd:ReleaseDC()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 08:57 AM

Antonio,

De tu codigo, me viene una idea:

Tu funcion lightborder() intenta pintar fuera del oGet, en el dialogo , en el momento del oGet:Paint() del oGet, fuera de los limites del oGet usando un hDC del dialogo.Recuerdo vagamente que hace tiempo vez intente lo mismo (o similar) sin exito. Entonces lo achaqué a mis pobres conocimientos.

En su dia hasta donde investigué, descubrí que los controles tienen un pintado non client o algo asi, de manera que quiza lo que habria que hacer seria utilizar un pintado non client en un el evento de pintado non client del control y para ello el method :handleevent() de controls.prg deberia recoger el evento WM_NCPAINT y crear una data ::bNCPainted que seria la que contuviera la llamada al lightborder()

Todo dicho con mucho recato: no se si seria la solucion. Perdon por mi vaguedad de conceptos...

Saludos.

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 09:25 AM

Paco,

Podriamos usar eso pero vendría a ser lo mismo.

En mi código ya se pinta encima del diálogo. Lo que no se es porque no se ven los sucesivos rectángulos en diferentes posiciones.

A ver si a alguien se le ocurre algo (Daniel, Manuel, Cristobal! Help!) :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 458
Joined: Tue Mar 14, 2006 07:26 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 10:21 AM

Antonio,

No lo he probado, pero creo que falla el hDC, con esos 2 parámetros, no se necesita el oGet, prueba así:

oGet:bPainted = { |hDC| LightBorder( hDC, oGet:HWnd ) }

Un Saludo,

Joaquín Martínez
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 10:34 AM
yo creo que el problema es que solo se pinta el ultimo recuadro, he hecho el pintado a la inversa de fuera hacia adentro.
el codigo que me funciona :

Code (fw): Select all Collapse
function pintaselect(oItem)

   local hDC := oItem:oWnd:GetDC()
   local hBrush, hOldBrush, n
   local aTopLeft, aBottomRight
   local oPen,hPen1
   local aRect := GetClientRect( oItem:hWnd )


   for n = 1 to 10
      hPen1 = CreatePen( PS_SOLID, 1,  nRGB( Int(189- (n ^ 2)), Int(230-(n ^ 2) ) , 252 ) )
    //  SelectObject( hDC, oPen := TPen():New( ,, nRGB( n ^ 2, n ^ 2, 200 ) ):hPen )

      SelectObject( hDC,hPen1)
      aTopLeft = ClientToScreen( oItem:hWnd, { aRect[1], aRect[2] } )
      aTopLeft = ScreenToClient( oITem:oWnd:hWnd, aTopLeft )

      aBottomRight = ClientToScreen( oItem:hWnd, {aRect[3], aRect[4] } )
      aBottomRight = ScreenToClient( oItem:oWnd:hWnd, aBottomRight )

      SetBkMode( hDC , 1 )

      Rectangle( hDC, aTopLeft[1]-12 + n, aTopLeft[2]-12+ n, aBottomRight[ 1 ]+12 -n,  aBottomRight[ 2 ]+12-n )

      DeleteObject( hPen1 )

   next

   oItem:oWnd:ReleaseDC()
Return nil
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 11:08 AM
Perdon por mi insistencia, obvíese este comentario pero google insiste en que hay que usar el WM_NCLIENT :-)

Aqui un ejemplo:
Code (fw): Select all Collapse
case WM_NCPAINT:

   {
       HDC hdc;
       RECT rect;
       HBRUSH b;
       HPEN pe;
 
       hdc=GetDCEx(hwnd,(HRGN)wParam,DCX_WINDOW|DCX_CACHE|DCX_INTERSECTRGN|DCX_LOCKWINDOWUPDATE);
       GetWindowRect(hwnd,&rect);
       b=CreateSolidBrush(RGB(0,180,180));
       SelectObject(hdc,B)/>;
       pe=CreatePen(PS_SOLID, 1, RGB(90, 90, 90));
       SelectObject(hdc,pe);
       Rectangle(hdc,0,0,(rect.right-rect.left),(rect.bottom-rect.top));
       DeleteObject(pe);
       DeleteObject(B)/>;
 
       ReleaseDC(hwnd,hdc);
       RedrawWindow(hwnd,&rect,(HRGN)wParam,RDW_UPDATENOW);
       return 0;
 
   }


desde http://www.dreamincode.net/forums/topic ... ndows-api/

Ojalá se pueda hacer sin tener que usar el WM_NCPAINT.

Saludos a todos.
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 11:25 AM
version mejorada....

Code (fw): Select all Collapse
pintaselect( oItem)

  local hDC := oItem:oWnd:GetDC()
   local hBrush, hOldBrush, n
   local aTopLeft, aBottomRight
   local oPen,hPen1
   local aRect := GetClientRect( oItem:hWnd )


   for n = 1 to  6
      IF n > 5
         hPen1 = CreatePen( PS_SOLID, 1,  nRGB(102 , 175, 233 ) )
      ELSE
         hPen1 = CreatePen( PS_SOLID, 1,  nRGB( Int(254 - n*3-n ), Int(254- n*2 ) , 255 ) )
      endif
   //   hPen1 = CreatePen( PS_SOLID, 1,  nRGB( Int(244 - n ), Int(254- n ) , 255 ) )
    //  SelectObject( hDC, oPen := TPen():New( ,, nRGB( n ^ 2, n ^ 2, 200 ) ):hPen )

      SelectObject( hDC,hPen1)
      aTopLeft = ClientToScreen( oItem:hWnd, { aRect[1], aRect[2] } )
      aTopLeft = ScreenToClient( oITem:oWnd:hWnd, aTopLeft )

      aBottomRight = ClientToScreen( oItem:hWnd, {aRect[3], aRect[4] } )
      aBottomRight = ScreenToClient( oItem:oWnd:hWnd, aBottomRight )

      SetBkMode( hDC , 1 )

      Rectangle( hDC, aTopLeft[1]-8 + n, aTopLeft[2]-8+ n, aBottomRight[ 1 ]+8 -n,  aBottomRight[ 2 ]+8-n )

      DeleteObject( hPen1 )

   next

   oItem:oWnd:ReleaseDC()

Return nil
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 12:15 PM
Excelente...

Code (fw): Select all Collapse
#Include "FiveWin.ch"

function Main()

   local oDlg, cTest := Space( 20 ), oGet

   DEFINE DIALOG oDlg 

   @ 2, 3 GET oGet VAR cTest OF oDlg SIZE 100, 13

   oGet:bPainted = { || LightBorder( oGet ) }

   ACTIVATE DIALOG oDlg CENTERED

return nil

//Function pintaselect( oItem )
function LightBorder( oGet )

   local hDC := oGet:oWnd:GetDC()
   local hBrush, hOldBrush, n
   local aTopLeft, aBottomRight
   local oPen,hPen1
   local aRect := GetClientRect( oGet:hWnd )

   for n = 1 to 6  // 10 es mejor

      IF n > 5
         hPen1 = CreatePen( PS_SOLID, 1,  nRGB( 102 , 175, 233 ) )
      ELSE
         hPen1 = CreatePen( PS_SOLID, 1,  nRGB( Int(254 - n*3-n ), Int(254- n*2 ) , 255 ) )
      endif

      // hPen1 = CreatePen( PS_SOLID, 1,  nRGB( Int(244 - n ), Int(254- n ) , 255 ) )
      // SelectObject( hDC, oPen := TPen():New( ,, nRGB( n ^ 2, n ^ 2, 200 ) ):hPen )

      SelectObject( hDC,hPen1)
      aTopLeft = ClientToScreen( oGet:hWnd, { aRect[1], aRect[2] } )
      aTopLeft = ScreenToClient( oGet:oWnd:hWnd, aTopLeft )

      aBottomRight = ClientToScreen( oGet:hWnd, {aRect[3], aRect[4] } )
      aBottomRight = ScreenToClient( oGet:oWnd:hWnd, aBottomRight )

      SetBkMode( hDC , 1 )

      Rectangle( hDC, aTopLeft[1]-8 + n, aTopLeft[2]-8+ n, aBottomRight[ 1 ]+8 -n,  aBottomRight[ 2 ]+8-n )

      DeleteObject( hPen1 )

   next

   oGet:oWnd:ReleaseDC()

Return nil


Gracias.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 12:42 PM

Genial Antonio, Manuel !! ya hay luz...
Para completar, si no es mucho molestar... ahora faltaria que se pinte solo cuando el oGet (o oontrol) tenga el foco con luz (no se si GetFocus() == oGet:hWnd) y ademas que se apague en el oGet (o control) que antes tenia el foco con luz.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Luz en la caja del get
Posted: Fri Nov 14, 2014 01:00 PM
Ejemplo: FWH..\SAMPLES\HOLLOW.PRG - Excelente.

Code (fw): Select all Collapse
#include "Fivewin.ch"

Function Test()

   Local oDlg, oFont, oBmp, cTest := Space( 20 ), oGet

   DEFINE BITMAP oBmp FILE "..\bitmaps\back.bmp"
   DEFINE FONT oFont NAME "Arial" SIZE 0,-36 BOLD NESCAPEMENT 250 //Texto 45º

   DEFINE DIALOG oDlg FROM 0,0 to 18,40 TITLE "Texto sin relleno"

   @ 2, 3 GET oGet VAR cTest OF oDlg SIZE 100, 13 ;
          COLORS CLR_HRED, CLR_WHITE

   oGet:bPainted = { || LightBorder( oGet ) }

   ACTIVATE DIALOG oDlg CENTERED ON PAINT;
     (DrawBitmap(oDlg:hDC,oBmp:hBitmap,0,0,oDlg:nWidth,oDlg:nHeight),;
      HollowText(oDlg,200,20," Texto sin relleno ",oFont,CLR_GREEN,2))

   RELEASE FONT oFont
   RELEASE BITMAP oBmp

return nil
*************************************************************************
*
* Function HollowText(oDlg,y,x,cText,oFont,nColor,nWidth,nStyle)
*
* Dibuja sólo el contorno de un texto
*  oDlg: Contenedor 
*  y,x : Coordenadas
*  oFont: Fuente
*  nColor, nWidth, nStyle: Color, ancho y estilo de contorno
*  
*  César E. Lozada          cesarlozada@hotmail.com
*  Los Teques, Venezuela    17-Abr-2003
*
*************************************************************************
Function HollowText(oDlg,y,x,cText,oFont,nColor,nWidth,nStyle)
  Local hDC:=oDlg:hDC
  Local nOldFont, hPen, hOldPen 
  DEFAULT oFont:=oDlg:oFont, nColor:=oDlg:nClrText,;
          nWidth:=1, nStyle:=0 //PS_SOLID 

  nOldFont:=SelectObject(hDC,oFont:hFont)
  hPen:=CreatePen(nStyle,nWidth,nColor)
  hOldPen:=SelectObject(hDC,hPen)

  BeginPath(hDC)
  TextOut(hDC,y,x,cText,Len(cText))
  EndPath(hDC)
  StrokePath(hDC)

  SelectObject(hDC,nOldFont)
  SelectObject(hDC,hOldPen)
  DeleteObject(hPen)

return nil

function LightBorder( oGet )

   local hDC := oGet:oWnd:GetDC()
   local hBrush, hOldBrush, n
   local aTopLeft, aBottomRight
   local oPen,hPen1
   local aRect := GetClientRect( oGet:hWnd )

   for n = 1 to 10

      IF n > 5
         //hPen1 = CreatePen( PS_SOLID, 1,  nRGB( 102 , 175, 233 ) )  // blue
         hPen1 = CreatePen( PS_SOLID, 1,  RGB( 255, 165, 000 ) )      // orange
      ELSE
         hPen1 = CreatePen( PS_SOLID, 1,  nRGB( Int(254 - n*3-n ), Int(254- n*2 ) , 255 ) )
      endif

      // hPen1 = CreatePen( PS_SOLID, 1,  nRGB( Int(244 - n ), Int(254- n ) , 255 ) )
      // SelectObject( hDC, oPen := TPen():New( ,, nRGB( n ^ 2, n ^ 2, 200 ) ):hPen )

      SelectObject( hDC,hPen1)
      aTopLeft = ClientToScreen( oGet:hWnd, { aRect[1], aRect[2] } )
      aTopLeft = ScreenToClient( oGet:oWnd:hWnd, aTopLeft )

      aBottomRight = ClientToScreen( oGet:hWnd, {aRect[3], aRect[4] } )
      aBottomRight = ScreenToClient( oGet:oWnd:hWnd, aBottomRight )

      SetBkMode( hDC , 1 )

      Rectangle( hDC, aTopLeft[1]-8 + n, aTopLeft[2]-8+ n, aBottomRight[ 1 ]+8 -n,  aBottomRight[ 2 ]+8-n )

      DeleteObject( hPen1 )

   next

   oGet:oWnd:ReleaseDC()

Return nil

*************************************************************************
DLL32 STATIC FUNCTION BeginPath;
      ( hdc AS LONG ) ;
   AS LONG PASCAL; 
   LIB "GDI32"

DLL32 STATIC FUNCTION EndPath;
      ( hdc AS LONG ) ;
   AS LONG PASCAL; 
   LIB "GDI32"

DLL32 STATIC FUNCTION StrokePath;
      ( hdc AS LONG ) ;
   AS LONG PASCAL; 
   LIB "GDI32"
*************************************************************************


João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341