Page 1 of 1

_WhenHideEval in _dcclass.prg

Posted: Tue Jan 31, 2023 3:06 am
by skiman
Hi,

It looks to me that there is a problem in the _WhenHideEval function. I solved it for me, so I don't expect any changes in eXPress++.

Just to be sure that I understand it correctly. My question is for the HIDE clause.

Suppose the following in a dialog.

A GET for a variable cName.
A checkbox with a HIDE {|| empty(cName) }

So at creation the checkbox is hidden.

If I'm correct, the HIDEBLOCK of the checkbox will never be evaluated?

Code: Select all

STATIC FUNCTION _WhenHideEval( lEnable, lShow, lProtect, oXbp )

IF Valtype(oXbp:whenBlock) = 'B'
  lEnable:= Eval(oXbp:whenBlock,oXbp)
  IF lEnable
    oXbp:enable()
  ELSE
    oXbp:disable()
  ENDIF
ENDIF

IF Valtype(oXbp:hideBlock) = 'B' .AND. oXbp:isVisible() ;     -------------------------------------> hidden at creation, so isvisible() will be False and it will never be executed????
      .AND. IIF(oXbp:parent:isDerivedFrom('XbpTabPage'),IIF(oXbp:parent:Minimized,.f.,.t. ),.t. )
  lShow := !Eval(oXbp:hideBlock,oXbp)
  IF lShow
    oXbp:show()
  ELSE
    oXbp:hide()
  ENDIF
ENDIF

IF Valtype(lProtect) == 'L' .AND. Valtype(oXbp:protectBlock) = 'B'
  lProtect := Eval(oXbp:protectBlock,oXbp)
ENDIF

RETURN oXbp
Maybe I'm wrong and I don't understand the logical flow of this, but it looks very strange to me.

Re: _WhenHideEval in _dcclass.prg

Posted: Tue Jan 31, 2023 9:12 am
by rdonnay
The codeblock is evaluated when DC_GetRefresh(GetList) or DC_GetWhen(GetList) or DC_GetWhen(<oCheckBox>) or DC_GetRefresh(<oCheckBox>) is called.

Re: _WhenHideEval in _dcclass.prg

Posted: Tue Jan 31, 2023 10:14 am
by skiman
Hi Roger,

Yes, I know. But only when isvisible() is true. I don't understand how it can get evaluated once isvisible() is False?

Re: _WhenHideEval in _dcclass.prg

Posted: Tue Jan 31, 2023 11:07 am
by rdonnay
I just noticed that the code you posted is not the same as the code in the latest release.

This was a fix that was made shortly after the build 268 release.
You will need to make this change and rebuild dclipx.dll by running build20.bat

Code: Select all

STATIC FUNCTION _WhenHideEval( lEnable, lShow, lProtect, oXbp )

IF Valtype(oXbp:whenBlock) = 'B'
  lEnable:= Eval(oXbp:whenBlock,oXbp)
  IF lEnable
    oXbp:enable()
  ELSE
    oXbp:disable()
  ENDIF
ENDIF

IF Valtype(oXbp:hideBlock) = 'B' ;
      .AND. IIF(oXbp:parent:isDerivedFrom('XbpTabPage'),IIF(oXbp:parent:Minimized,.f.,.t. ),.t. )

  lShow := !Eval(oXbp:hideBlock,oXbp)
  IF lShow .AND. !oXbp:isVisible()
    oXbp:show()
  ELSEIF !lShow .AND. oXbp:isVisible()
    oXbp:hide()
  ENDIF
ENDIF

IF Valtype(lProtect) == 'L' .AND. Valtype(oXbp:protectBlock) = 'B'
  lProtect := Eval(oXbp:protectBlock,oXbp)
ENDIF

RETURN oXbp

Re: _WhenHideEval in _dcclass.prg

Posted: Wed Feb 01, 2023 1:09 am
by skiman
Hi Roger,

That makes more sense.

I also have IsMethod(oXbp,'PARENT') added to the check.