Skip to content

Instantly share code, notes, and snippets.

@CarlTBarnes
Last active September 22, 2022 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlTBarnes/a2d910ecea78d4d3ddea6201ee72adba to your computer and use it in GitHub Desktop.
Save CarlTBarnes/a2d910ecea78d4d3ddea6201ee72adba to your computer and use it in GitHub Desktop.
GROUP Move and also All Child Controls X,Y Position
!When a GROUP X/Y Position is changed it does NOT move the Child Controls
!This loops through the child controls and moves each one
!
!The XAdjust / YAdjust parameters allow some extra move from the TO Control X/Y
!------------------------------------------------------------------------------------
MAP
GroupMoveChildren(LONG FromGroup, LONG ToControl, LONG XAdjust=0, LONG YAdjust=0)
END
!------------------------------------------------------------------------------------
GroupMoveChildren PROCEDURE(LONG FrmGrp, LONG ToGrp, LONG XAdjust=0, LONG YAdjust=0)
DX LONG,AUTO !Destination (To X), then Delta X
DY LONG,AUTO
FX LONG,AUTO
FY LONG,AUTO
ChildNdx LONG,AUTO
ChildFEQ LONG,AUTO
CODE
IF ToGrp THEN
GETPOSITION(ToGrp,DX,DY)
ELSE
DX=0 ; DY=0 !Did not pass ToControl so just Adjust
END
DX+=XAdjust ; DY+=YAdjust
GETPOSITION(FrmGrp,FX,FY)
SETPOSITION(FrmGrp,DX,DY)
DX -= FX ; DY -= FY !Delta X/Y to apply to each Child
LOOP ChildNdx=1 TO 999
ChildFEQ=FrmGrp{PROP:Child,ChildNdx}
IF ~ChildFEQ THEN BREAK.
GETPOSITION(ChildFEQ,FX,FY)
SETPOSITION(ChildFEQ,FX+DX,FY+DY)
END
RETURN
!This does not move other Parent controls with Children inside the GROUP because PROP:Child does not see them.
!E.g. a GROUP can have a GROUP, OPTION or SHEET as a Child that contains child controls inside that.
!Should be able to spot that PROP:TYPE and make a Recursive call passing (ChildFEQ,0,Dx,Dy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment