FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Cambiar el borde a un Get *SOLUCIONADO*
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Cambiar el borde a un Get *SOLUCIONADO*
Posted: Sat Jan 23, 2021 07:11 AM
Hola.

Estoy haciendo una validación de datos ( Crsitobal :-) ) y me gustaría remarcar los valores que no son correctos. Lo ideal sería poder cambiar el borde del Get de dichos valores a otro color, por ejemplo rojo como hacen la mayoría de formularios web. Es posible?

He revisado la clase TGET y sus herencias pero no doy con la clave.

El resultado sería como este, el segundo get sería el inválido.
--------

¿ Y porque no ?

¿ And why not ?
Posts: 1515
Joined: Thu Oct 30, 2008 02:37 PM
Re: Cambiar el borde a un Get
Posted: Sat Jan 23, 2021 10:04 AM

Prueba asi oGet:bPainted:= {| hDC | DrawBox( 0, 0, oGet:nHeight, oGet:nWidth, hDC, 0, 0, 1, CLR_RED ) }

Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: Cambiar el borde a un Get
Posted: Sat Jan 23, 2021 03:52 PM
Gracias,

Con
oGet:bPainted:= {| hDC | DrawBox( 0, 0, oGet:nHeight, oGet:nWidth, hDC, 0, 0, 1, CLR_RED ) }
Me arroja el siguiente error:
Error description: Error BASE/1068 Argument error: array access
Args:
[ 1] = N 0
[ 2] = N 2

Stack Calls
===========
Called from: .\source\classes\TCALEX.PRG => DRAWBOX( 1830 )


He revisado la función DrawBox() de TCalex.PRG y solo recibe 3 parámetros:
Code (fw): Select all Collapse
FUNCTION DrawBox( hDC, aRect, nAdj )
   local aPoints
   DEFAULT nAdj := 0

   aPoints := { { aRect[ 2 ], aRect[ 1 ] },; //start
                { aRect[ 4 ], aRect[ 1 ] },; //top
                { aRect[ 4 ], aRect[ 3 ] },; //right
                { aRect[ 2 ], aRect[ 3 ] },; //Bottom
                { aRect[ 2 ], aRect[ 1 ] - nAdj } } //left

   PolyLine(  hDC,  aPoints )

return nil
Ajustando:
oGet2:bPainted:= {| hDC | DrawBox( hDC, { 0, 0, oGet2:nHeight, oGet2:nWidth } ) }
Me hace un cuadro "diferente" pero no se le puede pasar el color a DrawBox()

--------

¿ Y porque no ?

¿ And why not ?
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Cambiar el borde a un Get
Posted: Sat Jan 23, 2021 05:04 PM

Es muy interesante la funcionalidad que queres hacer.
En la clase TGraph hay metodos que te pueden ser de utilidad
METHOD DrawBox( nTop, nLeft, nBottom, nRight, nColor )
METHOD DrawLine( nY, nX, nHigh, nWidth, nColor, lDotted )
...
MESSAGE CreatePen METHOD _CreatePen()
METHOD DeletePen()

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Cambiar el borde a un Get
Posted: Sat Jan 23, 2021 05:22 PM

Why are you looking in tcalex.prg and tgraph.prg for drawing boxes?
TWindow class has a method Box and is available for every dialog and control too.

oWnd/oDlg/oCtrl:Box( nTop, nLeft, nBottom, nRight, uBorder, uBrush, aText )
uBorder can be Color constant, or oPen or hPen.

Regards



G. N. Rao.

Hyderabad, India
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: Cambiar el borde a un Get
Posted: Sun Jan 24, 2021 03:17 PM
cmsoft wrote:Es muy interesante la funcionalidad que queres hacer.
En la clase TGraph hay metodos que te pueden ser de utilidad
Gracias, estoy intentando emular el sistema de validaciones automáticos que lleva Laravel o Angular.
nageswaragunupudi wrote:Why are you looking in tcalex.prg and tgraph.prg for drawing boxes?
TWindow class has a method Box and is available for every dialog and control too.
Sorry, I got confused looking for the right function/method!
nageswaragunupudi wrote:oWnd/oDlg/oCtrl:Box( nTop, nLeft, nBottom, nRight, uBorder, uBrush, aText )
uBorder can be Color constant, or oPen or hPen.
Test with Box() Method of TGet Class but don't function....


Code:
#include 'fivewin.ch'

Function Main()

    Local oDlg 
    Local oGet1
    Local cVar1 := Space( 100 )
    Local oGet2
    Local cVar2 := Space( 100 )

    DEFINE DIALOG oDlg Resource "Dialogo2"

    Redefine Get oGet1 Var cVar1 Id 4004 Of oDlg

    Redefine Get oGet2 Var cVar2 Id 4001 Of oDlg
    oGet2:Box( 0, 0, oGet2:nHeight, oGet2:nWidth, CLR_RED )
    
    ACTIVATE DIALOG oDlg CENTER 

Return ( Nil )
Resource:
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 10.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL

DIALOGO2 DIALOG DISCARDABLE 14, 40, 330, 36
STYLE WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|WS_THICKFRAME|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE
EXSTYLE WS_EX_TRANSPARENT|WS_EX_CONTEXTHELP
CAPTION "Dialogo"
FONT 10, "Segoe UI Light"
{
  CONTROL "Edit", 4004, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 8, 4, 316, 12
  CONTROL "Edit", 4001, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 8, 20, 316, 12
}
--------

¿ Y porque no ?

¿ And why not ?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Cambiar el borde a un Get
Posted: Sun Jan 24, 2021 03:35 PM
#Include 'FiveWin.Ch'

#Define CLR_PINK       RGB( 255, 128, 128)

FUNCTION Main()

   Local oDlg, cTitle
   Local oGet1
   Local cVar1 := Space( 100 )
   Local oGet2
   Local cVar2 := Space( 100 )

   cTitle := OemToAnsi( "FIVEWIN: GET CON BORDES RED COLOR Y PAINT" )

   DEFINE DIALOG oDlg Resource "DIALOGO2" TITLE cTitle ;
      COLORS CLR_BLACK, CLR_WHITE TRANSPARENT

   oDlg: lHelpIcon := .F.

   REDEFINE GET oGet1 VAR cVar1 ID 4004 OF oDlg

   REDEFINE GET oGet2 VAR cVar2 ID 4001 OF oDlg
   
   ACTIVATE DIALOG oDlg CENTER                                               ;
      ON PAINT( oGet2:Box( -1, -1, oGet2:nHeight, oGet2:nWidth, CLR_HRED ) )

RETURN NIL
Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: Cambiar el borde a un Get
Posted: Sun Jan 24, 2021 03:41 PM
Thanks! it works fine with PAINT or bPainted and NOBORDER in resource.
This is the Result:
--------

¿ Y porque no ?

¿ And why not ?
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: Cambiar el borde a un Get
Posted: Tue Jan 26, 2021 02:33 PM
A vueltas con este tema, he conseguido que se muestren los bordes dependiendo de la validación del get que tengo montada, el problema es que los caracteres del get están arriba y cuando escribo se tapa la línea del borde superior. He estado revisando la clase tGet() para ver como puedo desplazar dichos caracteres hacia abajo pero no he encontrado nada.
El diálogo lo defino desde recurso y los gets están marcados sin borde



Gracias!
--------

¿ Y porque no ?

¿ And why not ?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Cambiar el borde a un Get
Posted: Tue Jan 26, 2021 03:15 PM

Cual és la FONT?

-1 -1, funciona perfecto con WorkShop.exe y el GET sin Border.

Saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: Cambiar el borde a un Get
Posted: Wed Jan 27, 2021 03:30 PM
karinha wrote:Cual és la FONT?

-1 -1, funciona perfecto con WorkShop.exe y el GET sin Border.

Saludos.


Utilizo esta:
Code (fw): Select all Collapse
::oFont := TFont():New ( 'Segoe UI', 0, -12,,,,,,,,,,,,,,,.f. )
--------

¿ Y porque no ?

¿ And why not ?
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: Cambiar el borde a un Get
Posted: Wed Jan 27, 2021 04:26 PM

En vez de oGet:Box he utilizado oGet:oWnd:Box y ya funciona bien sin tener que quitar el borde del get en el recurso, por lo que también se ha solucionado el problema que se eliminaba el marco al pasar el el cursor del ratón

--------

¿ Y porque no ?

¿ And why not ?
Posts: 29
Joined: Mon Jan 14, 2019 11:43 AM
Re: Cambiar el borde a un Get *SOLUCIONADO*
Posted: Thu Jan 28, 2021 08:29 AM

Hola
Puedes publicar el código, de cómo lo estás haciendo ?
Un saludo y gracias

Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM
Re: Cambiar el borde a un Get *SOLUCIONADO*
Posted: Thu Jan 28, 2021 07:48 PM
jgabri wrote:Hola
Puedes publicar el código, de cómo lo estás haciendo ?
Un saludo y gracias
                oGet:oWnd:Box ( oGet:nTop - 1,;
                oGet:nLeft - 1,;
                oGet:nTop + oGet:nHeight ,;
                oGet:nLeft + oGet:nWidth ,;
                { HexToRgb ( '#d4edda' ), 1 } )
--------

¿ Y porque no ?

¿ And why not ?
Posts: 29
Joined: Mon Jan 14, 2019 11:43 AM
Re: Cambiar el borde a un Get *SOLUCIONADO*
Posted: Fri Jan 29, 2021 08:06 PM

Mil gracias Víctor, funciona perfectamente !!