Auto Center Function Child Window Inside Parent
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | //==================================================================== // Function: gf_childautocenter() //-------------------------------------------------------------------- // Description: Auto-center function child window inside parent //-------------------------------------------------------------------- // Arguments: // value window aw_parent, the parent window for aw_child // value window aw_child, child window for aw_parent //-------------------------------------------------------------------- // Returns: (none) //-------------------------------------------------------------------- // Usage: gf_childautocenter ( window aw_parent, window aw_child ) // A way to call a function in the Open event of a centered window. // gf_childautocentr (gnv_app.of_GetFrame (), This) // Center The Window //-------------------------------------------------------------------- // Modify History: // //==================================================================== Integer li_Wp, li_Hp, li_Wc, li_Hc li_Wp = aw_parent.WorkSpaceWidth () //Work area width li_Hp = aw_parent.WorkSpaceHeight () //Workspace Height li_Wc = aw_child.Width //Child Window Width li_Hc = aw_child.Height //Child Window Height If li_Wc >= li_Wp Then aw_child.X = 0 ElseIf li_Wc < li_Wp Then aw_child.X = (li_Wp / 2) - (li_Wc /2) End If If li_Hc >= li_Hp Then aw_child.Y = 0 ElseIf li_Hc < li_Hp And li_Hc > li_Hp/2 Then aw_child.Y = 0 ElseIf li_Hc < li_Hp And li_Hc <= li_Hp/2 Then aw_child.Y = (li_Hp / 2) - li_Hc End If |
Good Luck!