DEL - CANC in Xbrowse

DEL - CANC in Xbrowse

Postby mauri.menabue » Fri Apr 23, 2021 11:48 am

Hi all

In GET defined in an XBROWSE grid where the rows have a height greater than 1
the DEL - CANC key does not clear the characters, so at the time of VALID the GET buffer is incorrect,
instead using the BACKSPACE button the erasure is correct.
If the cell height is 1 row everything is regular, I'm going to check out a test example.

Code: Select all  Expand view  RUN


#include "FiveWin.ch"

#define DBFLOCK_DEFAULT    0
#define DBFLOCK_CLIP       1
#define DBFLOCK_CL53       2
#define DBFLOCK_VFP        3
#define DBFLOCK_CL53EXT    4
#define DBFLOCK_XHB64      5

#define CLR_LBLUE     RGB( 217, 236, 255 )

*---------------------------------------------------------------------------
FUNCTION MAIN
*---------------------------------------------------------------------------

   LOCAL aStr := {}
   
   REQUEST DBFCDX
   REQUEST DBFFPT
   REQUEST HB_LANG_IT
   REQUEST HB_CODEPAGE_ITWIN

   HB_LANGSELECT("IT")
   HB_CDPSELECT("ITWIN")

   SET DBFLOCKSCHEME TO DBFLOCK_VFP
   SET DATE FORMAT   TO "dd/mm/yy"
   SET TIME FORMAT   TO "hh:mm:ss"
   SET EPOCH         TO year(date()) - 50
   SET DECIMAL       TO 2
   SET CENTURY       ON
   SET DELETED       ON
   SET OPTIMIZE      ON
   SET CONFIRM       ON
   SET SOFTSEEK      OFF
   SET EXCLUSIVE     OFF
   SET AUTOPEN       OFF

   SetGetColorFocus( CLR_LBLUE )
   SetBalloon( .T. )
   SetDialogEsc( .T. )

   aadd(aStr, { "CMP1" , "C", 25, 0 })
   aadd(aStr, { "CMP2" , "N",  8, 2 })
   aadd(aStr, { "CMP3" , "D",  8, 0 })
   aadd(aStr, { "CMP4" , "L",  1, 0 })
   aadd(aStr, { "CMP5" , "M", 10, 0 })

   IF .not. FILE("TestXbrw.dbf")
      DbCreate( "TestXbrw", aStr, "DBFCDX", .T., ("TESTDBF") )
   ELSE
      USE ("TestXbrw.dbf") NEW ALIAS ("TESTDBF") EXCLUSIVE
      IF NETERR()
         MSGSTOP("Non è possibile aprire il file : TestXbrw.dbf", "Errore")
         RETURN NIL
      ENDIF
   ENDIF

   *-XBROWSER ("TESTDBF") AUTOSORT FASTEDIT AUTOFIT SHOW SLNUM  TITLE "TEST"

   INPUT()
   
   CLOSE ("TESTDBF")
   
RETURN NIL


*---------------------------------------------------------------------------
STATIC FUNCTION INPUT ()
*---------------------------------------------------------------------------

   LOCAL oDlg
   LOCAL oGrd
   LOCAL oCol
   LOCAL oFont := tFont():new("Tahoma", 0, -12.00 ,,.F.,,,,.F.)

   DEFINE DIALOG oDlg ;
            SIZE 800, 600;
           TITLE "Test" ;
           PIXEL ;
           COLOR CLR_HBLUE ;
            FONT oFont

   @ 2, 2 XBROWSE oGrd ;
               OF oDlg ;
             SIZE -2 , -2 ;
            ALIAS ("TESTDBF") ;
            LINES ;
             CELL ;
         FASTEDIT ;
            PIXEL ;
            COLOR CLR_BLACK , CLR_WHITE  

   *----------------------------------------------
   *- Cmp1
   *----------------------------------------------
 
   ADD COLUMN oCol TO XBROWSE oGrd;
       DATA      FIELDWBLOCK("CMP1", select("TESTDBF"));
       PICTURE   "";
       TITLE     "Descrizione" + CRLF + "CMP1";
       ALIGN     LEFT ;
       SIZE      100.00;
       COLOR     CLR_BLACK, CLR_WHITE ;
       EDITABLE ;
       VALID     {|oGet , oGrd| Controlli( "CMP1", oGet:VarGet())}

       *-ON EDIT   {|o, oGet, nKey| ("TESTDBF")->CMP1 := oGet , Controlli("CMP1", oGet)}
 
   *----------------------------------------------
   *- Cmp2
   *----------------------------------------------
 
   ADD COLUMN oCol TO XBROWSE oGrd;
       DATA      FIELDWBLOCK("CMP2", select("TESTDBF"));
       PICTURE   "@E 99999.99";
       TITLE     "Numero" + CRLF + "CMP2";
       ALIGN     RIGHT ;
       SIZE      80.00;
       COLOR     CLR_BLACK, CLR_WHITE;
       EDITABLE ;
       VALID     {|oGet , oGrd| Controlli( "CMP2", oGet:VarGet())}
   
   *----------------------------------------------
   *- Cmp3
   *----------------------------------------------
 
   ADD COLUMN oCol TO XBROWSE oGrd;
       DATA      FIELDWBLOCK("CMP3", select("TESTDBF"));
       PICTURE   "";
       TITLE     "Data" + CRLF + "CMP3";
       ALIGN     LEFT ;
       SIZE      80.00;
       COLOR     CLR_BLACK, CLR_WHITE;
       EDITABLE ;
       VALID     {|oGet , oGrd| Controlli( "CMP3", oGet:VarGet())}

   *----------------------------------------------
   *- Cmp4
   *----------------------------------------------
 
   ADD COLUMN oCol TO XBROWSE oGrd;
       DATA      FIELDWBLOCK("CMP4", select("TESTDBF"));
       PICTURE   "";
       TITLE     "Logico" + CRLF + "CMP4";
       ALIGN     CENTER ;
       SIZE      80.00;
       COLOR     CLR_BLACK, CLR_WHITE ;
       EDITABLE ;
       VALID     {|oGet , oGrd| Controlli( "CMP4", oGet:VarGet())}

   *----------------------------------------------
   *- Propietà
   *----------------------------------------------

   oGrd:l2007    := .T.
   oGrd:bClrGrad := { | lInvert | If( ! lInvert, { { 0.50, 14342874, 16777215 } , { 0.50, 16777215, 14342874 } }  ,;
                                                 { { 0.50, 14342874, 16777215 } , { 0.50, 16777215, 14342874 } } ) }
   oGrd:nStretchCol         := STRETCHCOL_WIDEST
   oGrd:lMultiSelect        := .T.
   oGrd:nFooterHeight       := 20
   oGrd:lGradientComplete   := .t.
   oGrd:bClrHeader          := { || { CLR_BLACK , }  }
   oGrd:nColDividerStyle    := LINESTYLE_LIGHTGRAY
   oGrd:nRowDividerStyle    := LINESTYLE_LIGHTGRAY
   oGrd:lFitGridHeight      := .T.
   oGrd:lTabLikeExcel       := .T.
   oGrd:nMarqueeStyle       := MARQSTYLE_HIGHLROWRC
   oGrd:bClrRowFocus        := { || { CLR_BLACK, RGB(185,220,255) } }
   oGrd:lIncrFilter         := .F.
   oGrd:lSeekWild           := .F.
   oGrd:lSeekBar            := .F.
   oGrd:lColChangeNotify    := .T.
   oGrd:lColDividerComplete := .T.
   oGrd:lFooter             := .T.
   oGrd:lAutoSaves          := .T.          
   oGrd:SetChecks()
   oGrd:nDataLines          := 2
       
   AEval( oGrd:aCols, { |oCol| oCol:nHeadStrAlign := AL_CENTER  } )
       
   oGrd:CreateFromCode()    
   
   ACTIVATE DIALOG oDlg CENTER
   
   RELEASE oFont
   
RETURN NIL

*---------------------------------------------------------------------------
STATIC FUNCTION CONTROLLI ( cCmp, uVar )
*---------------------------------------------------------------------------

   DO CASE
      CASE cCmp == "CMP1"
           ? "Field " + "cCmp : " + ("TESTDBF")->CMP1
           ? "Get   : " + uVar
      CASE cCmp == "CMP2"
           ? "Field " + "cCmp : " + alltrim(str(("TESTDBF")->CMP2))
           ? "Get   : " + dtoc(uVar)
      CASE cCmp == "CMP3"
           ? "Field " + "cCmp : " + DTOC( ("TESTDBF")->CMP3 )
           ? "Get   : " + DTOC( ("TESTDBF")->CMP3 )
      CASE cCmp == "CMP4"
           ? "Field " + "cCmp : " + IF( ("TESTDBF")->CMP3 , "Y", "N")
           ? "Get   : " + IF( ("TESTDBF")->CMP3 , "Y", "N")
   ENDCASE

RETURN .T.
 


Thank you
User avatar
mauri.menabue
 
Posts: 155
Joined: Thu Apr 17, 2008 2:38 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 62 guests