Centering a Window on Your Desktop (Functions/Subroutines/Programs)
Created at 12 FEB 1998 09:33AM
The following code is to center a form on your desktop.
subroutine CenterWindow (void)
Declare Function Get_Property
Declare Subroutine Set_Property
** Get the size of the system (Resolution)
sysRes = Get_Property("SYSTEM" , "SIZE")
sysWidth = sysRes<3>
sysHeigth = sysRes<4>
** Get the size of the window to center
winSize = Get_Property(@WINDOW , "SIZE" )
winWidth = winSize<3>
winHeight = winSize<4>
** Get the coordinates for the new window. (The window should be first set to not visible)
winOffsetFromTop = (sysHeight - winHeight) / 2
winOffsetFromLeft = (sysWidth - winWidth) / 2
** Set the size of the window which will also make the form visible
Set_Property( @WINDOW , "SIZE" , winOffsetFromLeft:@FM:winOffsetFromTop:@FM:winWidth:@FM:winHeight)
return