Page 1 of 1

Array of Gets on a scroll panel

Posted: Wed Mar 24, 2021 6:08 am
by betoncu
Hi, I have five gets placed on a scrolling panel,
Initially all of them are disabled.
When I enable all of them (except third one) by using the function ChangeWhen, everything is OK. It works well.
But when I try to skip on the gets by hitting ENTER or TAB key, I cannot skip the third one which is disabled.

Please help.


Code: Select all | Expand

#include "fivewin.ch"
#INCLUDE "dtpicker.ch"

FUNCTION Main()
LOCAL oDlg, oFolder, aSayGet := {}, aGets := {}

   AAdd(aSayGet, {'Field-1 :', PadR('Field-1', 40), 200} )
   AAdd(aSayGet, {'Field-2 :', PadR('Field-2', 40), 200} )
   AAdd(aSayGet, {'Field-3 :', PadR('Field-3', 40), 200} )
   AAdd(aSayGet, {'Field-4 :', PadR('Field-4', 40), 200} )
   AAdd(aSayGet, {'Field-5 :', PadR('Field-5', 40), 200} )

   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL

   @ 10, 10 FOLDEREX oFolder PROMPT "&First", "&Second", "&Third" OF oDlg SIZE 480, 380 PIXEL
   oFolder:aEnable := { .T., .F., .F. }


   @ 20, 20 BUTTON 'Next >' SIZE 30, 13 PIXEL OF oFolder:aDialogs[1] ;
            ACTION ( oFolder:aEnable := { .F., .T., .F. }, ;
                     oFolder:SetOption(2), ;
                     ChangeWhen(@aGets), ;  //Call the function to change the When clauses to .T.
                     oDlg:UpDate() )


   ACTIVATE DIALOG oDlg CENTERED ;
            ON INIT  PlaceControls(@oDlg, @oFolder, @aSayGet, @aGets) ;
            ON PAINT  aGets[1]:SetFocus()

RETURN NIL


FUNCTION PlaceControls(oDlg, oFolder, aSayGet, aGets)
LOCAL oPanel, nI, nRow, aGetObj[ Len(aSayGet) ]

   oPanel := TScrollPanel():New( 0, 0, 195, 470, oFolder:aDialogs[2], .T. )
   oFolder:aDialogs[2]:oClient := oPanel

   nRow:= 10

   FOR nI=1 to Len(aSayGet)
   
      @ nRow,  20 SAY aSayGet[nI, 1] OF oPanel SIZE 100,21 PIXEL RIGHT TRANSPARENT

      @ nRow, 125 GET aGetObj[nI] VAR aSayGet OF oPanel SUBSCRIPT nI, 2 SIZE aSayGet[nI, 3], 21 PIXEL WHEN .F.  //Initially disabled
     
      AAdd( aGets, aGetObj[nI] )

      nRow += 23
   NEXT

   oPanel:SetRange()

RETURN NIL


FUNCTION ChangeWhen(aGets)
LOCAL nI

   FOR nI = 1 TO Len(aGets)
      IF nI <> 3
         aGets[nI]:bWhen := {|| .T.}   //Change bWhen clause of all gets to .T. except third element
      ENDIF
   NEXT

RETURN NIL

Re: Array of Gets on a scroll panel

Posted: Thu Mar 25, 2021 8:02 am
by betoncu
Mr. Rao. Do you have any advise about this problem. Please

Re: Array of Gets on a scroll panel

Posted: Thu Mar 25, 2021 10:20 am
by Antonio Linares
Birol,

If you remove the TScrollPanel then it works as expected

it seems as a bug to be fixed with TScrollPanel

Re: Array of Gets on a scroll panel

Posted: Thu Mar 25, 2021 10:24 am
by nageswaragunupudi
We'll check.

Re: Array of Gets on a scroll panel

Posted: Fri Mar 26, 2021 7:58 am
by nageswaragunupudi
When clause is not handled by ScrollPanel. This is a bug.
Fixed in next version.

Re: Array of Gets on a scroll panel

Posted: Fri Mar 26, 2021 8:01 am
by nageswaragunupudi
Please replace these two methods in TScrollPanel class

Code: Select all | Expand

METHOD GoNextCtrl( hCtrl ) CLASS TScrollPanel

   local nAt, hNext
   local nNext := 0

   nAt := AScan( ::aControls, { | o | o:hWnd == hCtrl } )
   if nAt > 0
      hNext    := NextDlgTab( ::hWnd, hCtrl )
      nNext    := AScan( ::aControls, { |o| o:hWnd == hNext } )
      ::hCtlFocus := hCtrl
      if nNext < nAt .and. Len( ::oWnd:aControls ) > 1
         ::oWnd:GoNextCtrl( ::hWnd )
      else
         SetFocus( hNext )
      endif
   endif

return nil

//----------------------------------------------------------------------------//

METHOD GoPrevCtrl( hCtrl ) CLASS TScrollPanel

   local nAt, hPrev
   local nPrev := 0

   nAt := AScan( ::aControls, { | o | o:hWnd == hCtrl } )
   if nAt > 0
      hPrev    := NextDlgTab( ::hWnd, hCtrl, .t. )
      nPrev    := AScan( ::aControls, { |o| o:hWnd == hPrev } )
      ::hCtlFocus := hCtrl
      if ( nPrev == 0 .or. nPrev > nAt ) .and. Len( ::oWnd:aControls ) > 1
         ::oWnd:GoPrevCtrl( ::hWnd )
      else
         SetFocus( hPrev )
      endif
   endif

return nil
 

Re: Array of Gets on a scroll panel

Posted: Fri Mar 26, 2021 8:55 am
by Silvio.Falconi
Nages,
when I use the scrollpanel in a dialog sized by the user (oDlg: bResized), the objects contained in it do not refresh themselves, i.e. they always have their own configuration,

for example

Image

if the user shrinks the dialog the btnbmp do not align according to the size of the dialog and at the same time of the resized control (scrpanel)

that is, if from the program I gave it the configuration to create files of 6 buttons, when the user resizes the dialog, the rows for 6 buttons will remain

Is it possible to have a horizontal scroll as well?

Re: Array of Gets on a scroll panel

Posted: Sat Mar 27, 2021 7:10 am
by betoncu
Thank you very much. It works.
There is only one problem left. I use SetGetColorFocus() to change get color when focused.
The color of the get does not change when I use dtpicker.

Thanks in advance.


Code: Select all | Expand

#include "fivewin.ch"
#INCLUDE "dtpicker.ch"

FUNCTION Main()
LOCAL oDlg, oFolder, aSayGet := {}, aGets := {}

   SetGetColorFocus()

   AAdd(aSayGet, {'Field-1 :', 'C', PadR('Field-1', 40), 200,         '@!'} )
   AAdd(aSayGet, {'Field-2 :', 'N',              234.45, 100, '999,999.99'} )
   AAdd(aSayGet, {'Field-3 :', 'D',              Date(), 100,          NIL} )
   AAdd(aSayGet, {'Field-4 :', 'C', PadR('Field-4', 40), 200,         '@!'} )
   AAdd(aSayGet, {'Field-5 :', 'N',                   0, 100, '999,999.99'} )

   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL

   @ 10, 10 FOLDEREX oFolder PROMPT "&First", "&Second", "&Third" OF oDlg SIZE 480, 380 PIXEL
   oFolder:aEnable := { .T., .F., .F. }

   ACTIVATE DIALOG oDlg CENTERED ;
            ON INIT  PlaceControls(@oDlg, @oFolder, @aSayGet, @aGets) ;
            ON PAINT  aGets[1]:SetFocus()

RETURN NIL



FUNCTION PlaceControls(oDlg, oFolder, aSayGet, aGets)
LOCAL oPanel, nI, nRow, oGet

   oPanel := TScrollPanel():New( 0, 0, 195, 470, oFolder:aDialogs[1], .T. )
   oFolder:aDialogs[1]:oClient := oPanel

   nRow:= 10

   FOR nI = 1 to Len(aSayGet)

      @ nRow, 005 SAY aSayGet[nI, 1] OF oPanel SIZE 150, 22 PIXEL RIGHT TRANSPARENT

      oGet := CreateGet(oPanel, nRow, 160, aSayGet, nI)

      AAdd(aGets, oGet )

      nRow += 25
   NEXT

   oPanel:SetRange()

RETURN NIL


FUNCTION CreateGet(oDlg, nRow, nCol, aSayGet, nI)
LOCAL oGet

   IF aSayGet[nI, 2] == 'D'
      @ nRow, nCol DTPICKER oGet VAR aSayGet[nI, 3] OF oDlg SIZE aSayGet[nI, 4], 22 PIXEL
   ELSE
      @ nRow, nCol GET oGet VAR aSayGet[nI, 3] OF oDlg SIZE aSayGet[nI, 4], 22 PIXEL UPDATE PICTURE aSayGet[nI, 5]
   ENDIF

RETURN oGet
 

Re: Array of Gets on a scroll panel

Posted: Sat Mar 27, 2021 7:23 am
by betoncu
Also, when I click on dtpicker to change the day, month or year manually, it does not focused. It acts as it is readonly.
If I use WindowsXP.Manifest, I can solve this problem. It is focused and does not acts as readonly when I click on it.

Only highlighting problem left now. When I use tabs to skip amoung the gets, dtpicker does not highlighted.

Re: Array of Gets on a scroll panel

Posted: Sat Mar 27, 2021 8:10 am
by nageswaragunupudi
SetGetColorFocus() works for Gets only. Not for dtpicker.

Re: Array of Gets on a scroll panel

Posted: Sat Mar 27, 2021 8:28 am
by betoncu
Ok. But it is not highlighted when focused.