Dear All,
How to make border around Get like this
I need to put this on empty Get Object and remove if filled with value..
Regards,
Frances
Silvio wrote:
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 ....
#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
// 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.
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 14 guests