Page 1 of 3

Border around GET

Posted: Fri May 14, 2010 12:03 am
by fraxzi
Dear All,

How to make border around Get like this
Image


I need to put this on empty Get Object and remove if filled with value..


Regards,
Frances

Re: Border around GET

Posted: Fri May 14, 2010 8:24 am
by Silvio
Image
on Paint method
BEFORE ::DispEnd( aInfo )

RoundRect(::hDc,0,0,::nWidth-1,::nHeight-1,9,9)

THEN TRY WITH XPLOOK.RC

DEFINE DIALOG oDlg SIZE 400,200 TITLE "I am a DialogBox"

@ 2, 3 GET oGet var cTest OF oDlg NOBORDER
@ 6, 3 GET oGet var cTest OF oDlg NOBORDER

ACTIVATE DIALOG oDlg CENTERED



BUT THIS IS ONLY AN small idea ....

Re: Border around GET

Posted: Wed May 19, 2010 5:25 am
by fraxzi
Silvio wrote:Image
on Paint method
BEFORE ::DispEnd( aInfo )

RoundRect(::hDc,0,0,::nWidth-1,::nHeight-1,9,9)

THEN TRY WITH XPLOOK.RC

DEFINE DIALOG oDlg SIZE 400,200 TITLE "I am a DialogBox"

@ 2, 3 GET oGet var cTest OF oDlg NOBORDER
@ 6, 3 GET oGet var cTest OF oDlg NOBORDER

ACTIVATE DIALOG oDlg CENTERED

BUT THIS IS ONLY AN small idea ....

Dear Silvio,

Thank you for the idea.. I really appreciate it..

I wish a method not to change class.. and border is much larger where I can revert to default (or remove it) when validation is ok.


Best regards,
Frances

Re: Border around GET

Posted: Wed May 19, 2010 12:03 pm
by ukoenig
Maybe ( with any Color and Pen-Size ) ???

Image

REDEFINE GET oGET1 VAR cGET1 ID 250 OF oDlg UPDATE
// TOP, LEFT, hDC, WIDTH, HEIGHT, PEN, COLOR
oGet1:bPainted := { |hDC| DRAWBOX( 0, 0, hDC, oGet1:nWidth-5, oGet1:nHeight-5, 3, 128 ) }

// -------- DRAW Get-BOX --------------------------------' )

STATIC FUNCTION DRAWBOX( nTOP, nLEFT, hDC, nLONG, nHIGHT, nPEN, nCOLOR )
LOCAL hPen := CREATEPEN( PS_SOLID, nPEN, nColor )
LOCAL hOldPen := SELECTOBJECT( hDC, hPen )

MOVETO( hDC, nTOP, nLEFT )
LINETO( hDC, nLong, 0 )
LINETO( hDC, nLONG, nHIGHT )
LINETO( hDC, 0, nHIGHT )
LINETO( hDC, 0, 0 )
SELECTOBJECT( hDC, hOldPen )
DELETEOBJECT( hPen )

RETURN NIL

================================

To move a Box to the foused Get is very easy :
Instead of Focus, You can change the Logic using Valid

Image

Use a Startflag for the 1. focused Get :

nPos := 1

REDEFINE GET oGET1 VAR cGET1 ID 250 OF oDlg UPDATE
// TOP, LEFT, hDC, WIDTH, HEIGHT, PEN, COLOR
oGet1:bPainted := { |hDC| IIF( nPos = 1, ( DRAWBOX( 0, 0, hDC, oGet1:nWidth-5, oGet1:nHeight-5, 3, 128 ), ;
DRAWBOX( 0, 0, hDC, 0, 0, 0, 0) ), NIL) }
oGet1:bGotFocus := { |hDC| nPos := 1, oGet2:Refresh(), oGet3:Refresh() }

REDEFINE GET oGET2 VAR cGET2 ID 260 OF oDlg UPDATE
oGet2:bPainted := { |hDC| IIF( nPos = 2, ( DRAWBOX( 0, 0, hDC, oGet2:nWidth-5, oGet2:nHeight-5, 3, 128 ), ;
DRAWBOX( 0, 0, hDC, 0, 0, 0, 0) ), NIL) }
oGet2:bGotFocus := { |hDC| nPos := 2, oGet1:Refresh(), oGet3:Refresh() }

REDEFINE GET oGET3 VAR cGET3 ID 270 OF oDlg UPDATE
oGet3:bPainted := { |hDC| IIF( nPos = 3, ( DRAWBOX( 0, 0, hDC, oGet3:nWidth-5, oGet3:nHeight-5, 3, 128 ), ;
DRAWBOX( 0, 0, hDC, 0, 0, 0, 0) ), NIL) }
oGet3:bGotFocus := { |hDC| nPos := 3, oGet1:Refresh(), oGet2:Refresh() }

============================

Using a Valid for the 1. get ( using Values for all Gets ) :
Shows a Red Box for the 3. Get, if the Value of the 3. Get > 100

REDEFINE GET oGET1 VAR nGET1 ID 250 OF oDlg UPDATE ;
VALID ( IIF( nGET3 > 100, ( nPos := 3, oGet1:Refresh(), oGet2:Refresh(), oGet3:Refresh() ), NIL ), .T. )
// TOP, LEFT, hDC, WIDTH, HEIGHT, PEN, COLOR
oGet1:bPainted := { |hDC| IIF( nPos = 1, ( DRAWBOX( 0, 0, hDC, oGet1:nWidth-5, oGet1:nHeight-5, 3, 128 ), ;
DRAWBOX( 0, 0, hDC, 0, 0, 0, 0) ), NIL) }
oGet1:bGotFocus := { |hDC| nPos := 1, oGet2:Refresh(), oGet3:Refresh() }

The VALID- results :

Image

Image

Best Regards
Uwe :lol:

Re: Border around GET

Posted: Wed May 19, 2010 6:32 pm
by lailton.webmaster

Re: Border around GET

Posted: Wed May 19, 2010 7:52 pm
by ukoenig
Maybe I don't understand the Question.
<around> means just a Frame to me, <Round> means a round Border ???
As well a Solution needed :

.... where I can revert to default (or remove it) when validation is ok.

Best Regards
Uwe :?:

Re: Border around GET

Posted: Wed May 19, 2010 8:05 pm
by lailton.webmaster
Sorry

Re: Border around GET

Posted: Wed May 19, 2010 8:10 pm
by lailton.webmaster
I think that this solve your problem

nVar:=0

define dialog oDlg ....

redefine Get oGet Var nVar .... ON CHANGE validate( nVar, 100, oDlg )



function validate( nVar, nMax, oDialog )

if (nVar > nMax )

DRAWBOX....
else
oDialog:Refresh()
endif

return
return

Re: Border around GET

Posted: Thu May 20, 2010 12:48 am
by fraxzi
Dear Guys,

Thank you Laiton!

Thank you Uwe.. Your a great help..

I will immediately adapt your idea.


My Best Regards,
Frances

Re: Border around GET

Posted: Thu May 20, 2010 9:32 pm
by ukoenig
A complete Solution ( modified )
3 Tests You can activate / deactivate
All Types are supported : C, N, L, D

1. Show Box on Get-Focus
2. Show Box on empty Values on Init
3. Show Box with valid Values on Init

Image

Code: Select all

#include "fivewin.ch"

FUNCTION MAIN()
Local oDlg, hDC
Local oGet1,oGet2,oGet3,oGet4
local cVar1 := "Test"
local nVar2 := 100
local lVar3 := .F.
local dVar4 := DATE()

local oSay1, oSay2, oSay3, oSay4
local cSay1 := "Test"

local  oGetFont := TFont():New("Arial", ,-14,.F.,.T. , , , ,.T. )

SET DATE GERMAN
SET CENTURY ON

DEFINE DIALOG oDlg from 0,0 to 300, 300 pixel TITLE "Testing Boxes on GET"

@ 15, 50 get oGet1 var cVar1 picture "@!" size 50, 15 of oDlg pixel FONT oGetFont
// on Lostfocus delete Box
// -------------------------------
oGet1:bLostFocus := {|hDC| GETBOX( oGet1, hDC, NIL, NIL, NIL, NIL, .F. ) } 

@ 40, 50 get oGet2 var nVar2 picture "99999" size 50,15 of oDlg pixel  FONT oGetFont
oGet2:bLostFocus := {|hDC| GETBOX( oGet2, hDC, NIL, NIL, NIL, NIL, .F. ) }

@ 65, 50 get oGet3 var lVar3 size 50,15 of oDlg pixel  FONT oGetFont
oGet3:bLostFocus := {|hDC| GETBOX( oGet3, hDC, NIL, NIL, NIL, NIL, .F. ) }

@ 90, 50 get oGet4 var dVar4 PICTURE "##.##.####" size 50,15 of oDlg pixel  FONT oGetFont
oGet4:bLostFocus := {|hDC| GETBOX( oGet4, hDC, NIL, NIL, NIL, NIL, .F. ) }


// GETBOX( oGet, hDC, Getvar, Getcond, lValid, lEmpty, lStatus )
// ----------------------------------------------------------------------------------
// oGet
// hDC
// Getvar = Value
// Getcond = Valid Value
// lValid = Valid .T. or .F.
// lEmpty = Empty .T. or .F.
// lStatus = Show Box .T. or .F.

// Show Box on Get-Focus
// GETBOX( oGet, hDC, Getvar, Getcond, lValid, lEmpty, lStatus )
// ----------------------------------------------------------------------------------
oGet1:bGotFocus := {|hDC| GETBOX( oGet1, hDC, cVar1, "", .F., .F., .T. ) } 
oGet2:bGotFocus := {|hDC| GETBOX( oGet2, hDC, nVar2, 0, .F., .F., .T. ) } 
oGet3:bGotFocus := {|hDC| GETBOX( oGet3, hDC, lVar3, .F., .F., .F., .T. ) }
oGet4:bGotFocus := {|hDC| GETBOX( oGet4, hDC, dVar4, DATE(), .F., .F., .T. ) } 


// Draw Box for for all  empty Values
// GETBOX( oGet, hDC, Getvar, Getcond, lValid, lEmpty, lStatus )
// ----------------------------------------------------------------------------------
*GETBOX( oGet1, hDC, cVar1, "", .F., .T., .T. )
*GETBOX( oGet2, hDC, nVar2, 0, .F., .T., .T. )
*GETBOX( oGet3, hDC, lVar3, .F., .F., .T., .T. )
*GETBOX( oGet4, hDC, dVar4, CTOD("  .  .    "), .F., .T. )


// Init Box with Valid-Test
// GETBOX( oGet, hDC, Getvar, Getcond, lValid, lEmpty, lStatus )
// -----------------------------------------------------------------------------------
*GETBOX( oGet1, hDC, cVar1, "Test", .T., .F., .T. )  // NO Box
*GETBOX( oGet2, hDC, nVar2, 200, .T., .F., .T. )  // SHOW Box
*GETBOX( oGet3, hDC, lVar3, .T., .T., .F., .T. ) // SHOW Box
*GETBOX( oGet4, hDC, dVar4, DATE(), .T., .F., .T. ) // NO Box


@ 7, 9 BUTTON "&Cancel" ACTION oDlg:End() CANCEL

ACTIVATE DIALOG oDlg CENTERED
 
RETURN NIL

// --------- GET with Box --------------------------

FUNCTION GETBOX( oGet, hDC, Getvar, Getcond, lValid, lEmpty, lStatus )

IF lStatus = .T.
   IF ( lEmpty = .T. .and. EMPTY(Getvar) ) .or. ;
       ( lValid = .F. .and. lEmpty = .F. )  // Empty or Focus
      // TOP, LEFT, hDC, WIDTH, HEIGHT, PEN, COLOR
      oGet:bPainted := { |hDC| DRAWBOX( 0, 0, hDC, ;
      oGet:nWidth-5, oGet:nHeight-5, 5, 128 ) } 
   ENDIF
   IF VALTYPE ( Getvar ) = "C"
      // defined Valid
      IF lValid = .T. .and. Getvar <> Getcond   
         oGet:bPainted := { |hDC| DRAWBOX( 0, 0, hDC, ;
         oGet:nWidth-5, oGet:nHeight-5, 5, 128 ) } 
      ENDIF
   ELSEIF VALTYPE ( Getvar ) = "N"
      IF  lValid = .T. .and. Getvar < Getcond 
         oGet:bPainted := { |hDC| DRAWBOX( 0, 0, hDC, ;
         oGet:nWidth-5, oGet:nHeight-5, 5, 128 ) } 
      ENDIF
   ELSEIF VALTYPE ( Getvar ) = "L"
      IF lValid = .T. .and. Getvar <> Getcond 
         oGet:bPainted := { |hDC| DRAWBOX( 0, 0, hDC, ;
         oGet:nWidth-5, oGet:nHeight-5, 5, 128 ) } 
      ENDIF
   ELSEIF VALTYPE ( Getvar ) = "D"
      IF lValid = .T. .and. Getvar <> Getcond 
         oGet:bPainted := { |hDC| DRAWBOX( 0, 0, hDC, ;
         oGet:nWidth-5, oGet:nHeight-5, 5, 128 ) } 
      ENDIF
   ENDIF
ELSE
   oGet:bPainted := { |hDC| DRAWBOX( 0, 0, hDC, 0, 0, 0, 0) } 
ENDIF

RETURN NIL

// --------  DRAW BOX --------------------------------

STATIC FUNCTION DRAWBOX( nTOP, nLEFT, hDC, nLONG, nHIGHT, nPEN, nCOLOR ) 
LOCAL hPen := CREATEPEN( PS_SOLID, nPEN, nColor ) 
LOCAL hOldPen := SELECTOBJECT( hDC, hPen ) 

MOVETO( hDC, nTOP, nLEFT )
LINETO( hDC, nLong, 0 ) 
LINETO( hDC, nLONG, nHIGHT ) 
LINETO( hDC, 0, nHIGHT ) 
LINETO( hDC, 0, 0 )
SELECTOBJECT( hDC, hOldPen ) 
DELETEOBJECT( hPen ) 

RETURN NIL
 
Best Regards
Uwe :lol:

Re: Border around GET

Posted: Thu May 20, 2010 11:25 pm
by fraxzi
Dear Uwe,

Thank you so much for your kind and generous help.


Mabuhay!


Best Regards,
Frances

Re: Border around GET

Posted: Sun May 30, 2010 2:49 pm
by ukoenig
I tested still another Solution from Source
painting a BMP behind ( SAY and GET ) :

Image

A Gradient-Solution :
Image

Image

A special Border :
Image

Borders for SAY and GET calculated.
Say and Get must be placed before BMP :

@ 140,10 say oSay1 PROMPT "Row one" PIXEL FONT oGetFont
@ 138,5 BITMAP oBmp11 FILENAME "B_Blue2.bmp" ;
SIZE oSay1:nWidth + 10, oSay1:nHeight + 7 OF oDlg PIXEL ADJUST NOBORDER

@ 140, 100 GET oGet1 VAR cVar1 picture "@!" SIZE 50, 15 OF oDlg PIXEL FONT oGetFont
@ 138,95 BITMAP oBmp10 FILENAME "B_Red2.bmp" ;
SIZE oGet1:nWidth + 10, oGet1:nHeight + 7 OF oDlg PIXEL ADJUST NOBORDER

// Define the Border Start-Condition on Dialog-Init :

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oBmp10:Hide(), oBmp11:Hide() )

Hide / Show Border on Button-Action :

Code: Select all

// SAY with any Background-Bmp
@ 135,5 BITMAP oBmp11 FILENAME "B_Blue1.bmp" SIZE 68, 24 OF oDlg PIXEL ADJUST NOBORDER
@ 140,10 say oSay1 PROMPT "Row one" PIXEL FONT oGetFont

// GET with any Background-Bmp
@ 135,95 BITMAP oBmp10 FILENAME "B_Red1.bmp" SIZE 60, 25 OF oDlg PIXEL ADJUST NOBORDER
@ 140, 100 GET oGet1 VAR cVar1 picture "@!" SIZE 50, 15 OF oDlg PIXEL FONT oGetFont


@ 175, 175 BTNBMP oBtn3 OF oDlg 2007 ;
SIZE 60 , 30  PROMPT "Border ON" ;
FONT oGetFont ;
LEFT ;
NOBORDER ;
FILENAME "Tools.bmp" ;
ACTION (oBmp10:Show, oBmp11:Show )                                           
oBtn3:lTransparent := .T.
oBtn3:cTooltip := "  Desktop 1 "
oBtn3:lBorder := .F. 

@ 210, 175 BTNBMP oBtn3 OF oDlg 2007 ;
SIZE 60 , 30  PROMPT "Border OFF" ;
FONT oGetFont ;
LEFT ;
NOBORDER ;
FILENAME "Tools.bmp" ;
ACTION ( oBmp10:Hide, oBmp11:Hide )                                           
oBtn3:lTransparent := .T.
oBtn3:cTooltip := "  Desktop 1 "
oBtn3:lBorder := .F. 
 
Best Regards
Uwe :lol:

Re: Border around GET

Posted: Fri Jan 07, 2011 1:05 am
by fraxzi
Dear Uwe,

I tried with get multiline but it wont work.. How to do this with multiline get.. any idea?

Code: Select all

STATIC FUNCTION uDrawBoxOnGet( nTop, nLeft, hDC, nLong, nHeight, nPen, nColor, oGet )
 LOCAL hPen,;
       hOldPen
 
 hPen := CreatePen( PS_SOLID, nPen, nColor )
 hOldPen := SelectObject( hDC, hPen )
 
 MoveTo( hDC, nTop, nLeft )
 
 TRY
   LineTo( hDC, nLong-IF(oGet:oBtn == Nil,0,22), 0 )
   LineTo( hDC, nLong-IF(oGet:oBtn == Nil,0,22), nHeight )
 CATCH
   LineTo( hDC, nLong, 0 )           //in-case the oGet:oBtn doesn't exist
   LineTo( hDC, nLong, nHeight )
 END
 
 LineTo( hDC, 0, nHeight )
 LineTo( hDC, 0, 0 )
 SelectObject( hDC, hOldPen )
 DeleteObject( hPen )
 
RETURN
 

Kind Regards,
Frances

Re: Border around GET

Posted: Thu May 12, 2011 2:40 am
by fraxzi
Dear Mr. Uwe,

Any update on multiget border?


Kind Regards,
Frances

Re: Border around GET

Posted: Fri May 13, 2011 9:31 am
by ukoenig
Hello Frances,

I tested, moving the Border to the Dialog ( not insided the Get ) in Relation to the Multiline-get-dimension.
It seems, it could be a Solution.

Image

STATIC PROCEDURE Draw_Box(oDlg, oGet, nColor)
// x, y , nHigh, nWidht

// Top
DrawLine( oDlg, oGet:nTop - 5, oGet:nLeft - 5 , oGet:nTop - 5, oGet:nWidth + 32, 5, nColor )
// Bottom
DrawLine( oDlg, 125, oGet:nLeft - 5 , 125, oGet:nWidth + 32, 5, nColor ) // 32 needed for Scrollbar
// Left
DrawLine( oDlg, oGet:nTop - 5, oGet:nTop - 5 , 125, oGet:nLeft - 5, 5, nColor ) // 125 = Multiget-height
// Right
DrawLine( oDlg, oGet:nTop - 5, oGet:nWidth + 32 , 125, oGet:nWidth + 32, 5, nColor )

RETURN

Best Regards
Uwe :?: