Table of Contents

Centering an MDIChild Window Within an MDIFrame (Functions/Subroutines/Programs)

Created at 12 FEB 1998 09:31AM

The following sample code is to center the MDIChild within it's MDIFrame.

 

subroutine Center_MDIChild(void)

 

declare subroutine Start_MDIChild, Set_Property

declare function   Get_Property

 

**Get the parent of the window and then get the size

parent     = Get_Property(@WINDOW , "PARENT")

parentSize = Get_Property(parent , "SIZE")

 

**Get the size of the child window

childSize = Get_Property(@WINDOW , "SIZE")

 

**Subtract the child width from the parent width and divide the difference by 2

**Set the offset from the left of the child window to the result

iWidthDifference  = parentSize<3> - childSize<3>

iOffsetFromLeft   = iWidthDifference / 2

 

**Subtract the child height from the parent height and divide the difference by 2

**Set the offset from the top of the child window to the result

iHeightDifference = parentSize<4> - childSize<4>

iOffsetFromtop    = iHeightDifference / 2

 

**Set the size property of the child to make it centered and visible

Set_Property(@WINDOW , "SIZE" , iOffsetFromLeft:@FM:iOffsetFromtop:@FM:childSize<3>:@FM:childSize<4>)

Set_Property(@WINDOW , "FOCUS" , 1)

 

return