Using DTPICKER : wrong ROW coordinates

Using DTPICKER : wrong ROW coordinates

Postby Franklin Demont » Sun Nov 10, 2013 5:19 pm

Hello,

Next (litle) program has as goal in a dialog :

1) Any Valid clausule from a get should give a msgerror when VALID is used as
@ 1, 6 GET oGet VAR cCad OF oDlg SIZE 60, 10 PICTURE "@K" VALID MyValid(oGet,'oGet:Varget()="T"')
(see example)

2) The OK button has a when-clausule as
@ 3, 7 BUTTON "&Ok" OF oDlg SIZE 30, 12 ACTION oDlg:End() WHEN CheckValid(oDlg)
Checking every Valid clausule from oDlg:aControls , without showing the error message

3) When the input from a get doesn't satisfy the valid clausule , the original value should be restored

4) ESCAPE in the get restores also the original value

It seems to work.

BUT CHANGING :
@ 3, 6 GET oGet[3] VAR dDat PICTURE "@E" OF oDlg SIZE 60, 10 VALID MyValid(oGet[3],'YEAR(oGet:Varget())=2013')
TO
@ 3, 6 DTPICKER oGet[3] VAR dDat OF oDlg SIZE 60, 10 VALID MyValid(oGet[3],'YEAR(oGet:Varget())=2013')

Places this control wrong , overwriting the ok button

Why has the dtpicker dialog not the same coordinates on the screen ?

Frank Demont


Code: Select all  Expand view

#include "FiveWin.ch"
#include "DtPicker.ch"

function Main()
   LOCAL oDlg, oGet[3]
   LOCAL cCad := "Testing    "
   LOCAL nNum := 0
   LOCAL dDat := Date()

   Set century On
   Set Date French

   SET _3DLOOK ON

   DEFINE DIALOG oDlg TITLE "TGet from " + FWDESCRIPTION
   //DEFINE WINDOW oDlg TITLE "TGet from " + FWDESCRIPTION
   @ 1,    2 SAY "Text..:" OF oDlg
   @ 1,    6 GET oGet[1] VAR cCad OF oDlg SIZE 60, 10 PICTURE "@K" VALID MyValid(oGet[1],'oGet:Varget()="T"')
   @ 1.8,  2 SAY "Number:" OF oDlg
   @ 2,    6 GET oGet[2] VAR nNum OF oDlg SIZE 60, 10 PICTURE "9999999.99"
   @ 2.6,  2 SAY "Date:" OF oDlg
   @ 3,    6 GET oGet[3] VAR dDat PICTURE "@E" OF oDlg SIZE 60, 10 VALID MyValid(oGet[3],'YEAR(oGet:Varget())=2013')
   //@ 3,    6 DTPICKER oGet[3] VAR dDat OF oDlg SIZE 60, 10 VALID MyValid(oGet[3],'YEAR(oGet:Varget())=2013')
   //@ 40,   48 DTPICKER oGet[3] VAR dDat OF oDlg SIZE 60, 10 VALID MyValid(oGet[3],'YEAR(oGet:Varget())=2013') PIXEL
 @ 3,    7 BUTTON "&Ok" OF oDlg SIZE 30, 12 ACTION oDlg:End() WHEN CheckValid(oDlg)
   @ 3,   16 BUTTON "&Cancel" SIZE 30, 12 OF oDlg ACTION oDlg:End() CANCEL
   ACTIVATE DIALOG oDlg CENTERED ;
      VALID IIF(GetKeyState(27),DlgEsc(oDlg),.T.)

return nil

*********************************************************************************************
FUNCTION MyValid(oGet,cCond,cText,lRestore,lShow)
*************************************************
LOCAL bCond
LOCAL lOk := .T.
LOCAL Original := oGet:cCaption
DEFAULT lRestore := .T. , lShow := .T.
IF CheckProcList("CHECKVALID")
   lShow := .F.
END
IF ! ValType(cCond)$"BC"
   ? "Programmafout in Valid clausule" , ProcName(1) , ProcName(2)
   RETURN .T.
END
IF ValType(cCond) == "C"
   DEFAULT cText := ALLTRIM(cValToChar(oGet:Varget())) + " voldoet niet aan " + cCond + " !"
   bCond := &("{|oGet|" + cCond + "}")
ELSE
   cText := cValToChar(oGet:Varget()) + " : Ongeldige invoer"
END
lOk := EVAL(bCond,oGet)
IF ! lOk
   IF lShow
      MsgAlert(cText,"Ongeldige invoer")
   End
   IF lRestore
      oGet:Varput(Original)
      oGet:Refresh()
   END
END
RETURN lOk
******************************************************************************************

FUNCTION CheckValid(Self)
************************
LOCAL Obj
FOR EACH Obj IN ::aControls
    IF __ObjHasData(Self,"bValid")
       IF Obj:bValid <> nil .AND. VALTYPE(Obj:bValid) == "B"
          IF ! EVAL(Obj:bValid)  
             RETURN .F.
          END        
       END
    END
NEXT
RETURN .T.
******************************************************************************************
FUNC CheckProcList(cProc)
*************************
LOCAL ok := .F. , i := 0 , hlp
DO WHIL ! ok .AND. ! EMPTY(hlp := PROCNAME(i++))
 ok := (UPPER(cproc) IN hlp)
END
RETU ok
*****************************************************************************************
FUNC DlgEsc(Self)
*****************
LOCAL Obj , oGet
LOCAL Original
FOR EACH Obj IN ::aControls
    IF Obj:lFocused
       oGet := Obj
       EXIT
    END
NEXT
IF oGet <> nil
   Original := oGet:cCaption
   oGet:Varput(Original)
   oGet:Refresh()
END
RETURN .F.
 
test
Franklin Demont
 
Posts: 166
Joined: Wed Aug 29, 2012 8:25 am

Re: Using DTPICKER : wrong ROW coordinates

Postby Antonio Linares » Tue Nov 12, 2013 8:54 am

Frank,

When we originally designed FiveWin we thought about each class of control having its own coordinates system, why ? because if I want two GETs one above the other, I don't want that one overlaps the other, so the height is based on a GET height. In the case of the date picker, we have used a different height from the GET height. You have to modify the row of the date picker.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42094
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 68 guests