Cambiar el borde a un Get *SOLUCIONADO*

Cambiar el borde a un Get *SOLUCIONADO*

Postby VictorCasajuana » Sat Jan 23, 2021 7:11 am

Hola.

Estoy haciendo una validación de datos ( Crsitobal :D ) 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.
Image
Last edited by VictorCasajuana on Wed Jan 27, 2021 4:26 pm, edited 3 times in total.
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get

Postby hmpaquito » 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 ) }
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: Cambiar el borde a un Get

Postby VictorCasajuana » Sat Jan 23, 2021 3:52 pm

Gracias,

Con
Code: Select all  Expand view
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: Select all  Expand view
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:
Code: Select all  Expand view
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()
Image
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get

Postby cmsoft » Sat Jan 23, 2021 5: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()
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Cambiar el borde a un Get

Postby nageswaragunupudi » Sat Jan 23, 2021 5: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
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Cambiar el borde a un Get

Postby VictorCasajuana » Sun Jan 24, 2021 3: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....
Image

Code:
Code: Select all  Expand view

#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:
Code: Select all  Expand view
// 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 ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get

Postby karinha » Sun Jan 24, 2021 3:35 pm

Code: Select all  Expand view

#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
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Cambiar el borde a un Get

Postby VictorCasajuana » Sun Jan 24, 2021 3:41 pm

Thanks! it works fine with PAINT or bPainted and NOBORDER in resource.
This is the Result:
Image
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get

Postby VictorCasajuana » Tue Jan 26, 2021 2: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

Image

Gracias!
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get

Postby karinha » Tue Jan 26, 2021 3: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
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Cambiar el borde a un Get

Postby VictorCasajuana » Wed Jan 27, 2021 3:30 pm

karinha wrote:Cual és la FONT?

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

Saludos.


Utilizo esta:
Code: Select all  Expand view
::oFont := TFont():New ( 'Segoe UI', 0, -12,,,,,,,,,,,,,,,.f. )
--------
¿ Y porque no ?
¿ And why not ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get

Postby VictorCasajuana » Wed Jan 27, 2021 4: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 ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get *SOLUCIONADO*

Postby jgabri » Thu Jan 28, 2021 8:29 am

Hola
Puedes publicar el código, de cómo lo estás haciendo ?
Un saludo y gracias
jgabri
 
Posts: 19
Joined: Mon Jan 14, 2019 11:43 am

Re: Cambiar el borde a un Get *SOLUCIONADO*

Postby VictorCasajuana » Thu Jan 28, 2021 7:48 pm

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


Code: Select all  Expand view
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 ?
User avatar
VictorCasajuana
 
Posts: 194
Joined: Wed Mar 28, 2018 4:38 pm
Location: Vinaròs

Re: Cambiar el borde a un Get *SOLUCIONADO*

Postby jgabri » Fri Jan 29, 2021 8:06 pm

Mil gracias Víctor, funciona perfectamente !!
jgabri
 
Posts: 19
Joined: Mon Jan 14, 2019 11:43 am

Next

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests