Question about automatic disabling childs

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Markus Walter
Posts: 54
Joined: Thu Jan 28, 2010 12:49 am
Location: Germany

Question about automatic disabling childs

#1 Post by Markus Walter »

Hello Roger,

is it possible to have automatic disabled childs, if the parent is disabled about his WHEN-Block?

Sample:
I have a DCSTATIC Groupbox with 20 DCGETS on it. Now i would expect, that they are disabled, if the whenblock of the DCSTATIC is .f.
This would help much in complex dialogs.
Is this possible?
-----------------
Greetings
Markus Walter

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question about automatic disabling childs

#2 Post by rdonnay »

This should already work the way you suggest.

Are you saying that it does not?
The eXpress train is coming - and it has more cars.

User avatar
Markus Walter
Posts: 54
Joined: Thu Jan 28, 2010 12:49 am
Location: Germany

Re: Question about automatic disabling childs

#3 Post by Markus Walter »

Hi Roger,

please test the following:

Code: Select all

#include "dcdialog.ch"

function Appsys()
return NIL

procedure main()
local getlist := {}, getoptions := {}, lRet, oStatic, cVar1 := space(10), cVar2 := (10), cVar3 := (10), lAktiv := .t.

  @ 3,3 DCSTATIC TYPE XBPSTATIC_TYPE_GROUPBOX SIZE 20, 4 OBJECT oStatic WHEN {|| lAktiv}
  @ 1, 1 DCGET cVar1 PARENT oStatic
  @ 2, 1 DCGET cVar2 PARENT oStatic WHEN {|| lAktiv}

  @ 9, 3 DCGET cVar3

  @ 10, 3 DCPUSHBUTTON SIZE 10, 2 CAPTION "um" ACTION {|| if(lAktiv, lAktiv := .f., lAktiv := .t.), dc_getrefresh() }

  DCGETOPTIONS TITLE "Test"
  DCREAD GUI TO lRet OPTIONS getoptions FIT

RETURN
and press the Button. The first DCGET (without his own when clause) will not be disabled.
-----------------
Greetings
Markus Walter

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question about automatic disabling childs

#4 Post by rdonnay »

This appears to be a bug or a limitation of the Xbase++ XbpStatic class.

I tried several tests and could not make it work correctly.
The eXpress train is coming - and it has more cars.

User avatar
Markus Walter
Posts: 54
Joined: Thu Jan 28, 2010 12:49 am
Location: Germany

Re: Question about automatic disabling childs

#5 Post by Markus Walter »

Hi,

not nice to hear. This would be very handy witj complex screens.

What do you think about the idea to look from the Child: If one of the parent is disabled, it should be diabled, too?
-----------------
Greetings
Markus Walter

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question about automatic disabling childs

#6 Post by rdonnay »

Ok, here is your fix:

Replace the METHOD XbpStatic:WhenHideEval in _DCCLASS.PRG with the below code.
Rebuild dclipx.dll by running build19.bat.

Code: Select all

METHOD DC_XbpStatic:WhenHideEval( lEnable, lShow, lProtect )

LOCAL i, aChildList := ::childList()

IF Valtype(::whenBlock) = 'B'
  lEnable:= Eval(::whenBlock,self)
  IF lEnable
    ::enable()
    FOR i := 1 TO Len(aChildList)
      IF IsMethod(aChildList[i],'whenHideEval')
        IF IsMemberVar(aChildList[i],'whenBlock') .AND. Valtype(aChildList[i]:whenBlock) == 'B'
          aChildList[i]:whenHideEval( lEnable, lShow, lProtect )
        ELSEIF IsMethod(aChildList[i],'enable')
          aChildList[i]:enable()
        ENDIF
      ELSEIF IsMethod(aChildList[i],'enable')
        aChildList[i]:enable()
      ENDIF
    NEXT
  ELSE
    ::disable()
    FOR i := 1 TO Len(aChildList)
      IF IsMethod(aChildList[i],'disable')
        aChildList[i]:disable()
      ENDIF
    NEXT
  ENDIF
ENDIF

IF Valtype(::hideBlock) = 'B'
  lShow := !Eval(::hideBlock,self)
  IF lShow
    IF !::isVisible()
      ::show()
    ENDIF
  ELSE
    IF ::isVisible()
      ::hide()
    ENDIF
  ENDIF
ENDIF

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

RETURN self
The eXpress train is coming - and it has more cars.

User avatar
Markus Walter
Posts: 54
Joined: Thu Jan 28, 2010 12:49 am
Location: Germany

Re: Question about automatic disabling childs

#7 Post by Markus Walter »

Hello Roger,

thanks. That seems to work. Will this be part of the next build?
-----------------
Greetings
Markus Walter

User avatar
rdonnay
Site Admin
Posts: 4745
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Question about automatic disabling childs

#8 Post by rdonnay »

Yes, this will be in the next build.
The eXpress train is coming - and it has more cars.

Post Reply