Switch to standard view 
  Sybase logo
 
 
 



Automatic Window Centering Script

Information was provided by Kyle Griffis (Kyle.Griffis@hboc.com), a PowerBuilder Developer from HBO and Company (HBOC) located in Charlotte, NC.  HBOC is currently one of the top providers in the $13 billion healthcare informatics industry, HBOC serves the healthcare information systems needs of the health enterprise - hospitals, integrated health delivery networks and managed care organizations.  Visit their website at:  http://www.hboc.com

The following script should be placed in the open event of the window that is to be centered.  This code will automatically center that window regardless of the computer's resolution, OS, version of PowerBuilder or bit level:
 

/*********************************************************************************
 Description:  This will position the window in the center of the screen.

 Arguments:

 Return:       Boolean
**********************************************************************************
 History Log:
 Date:                               Who     What
-----------------------------------------------------------------------------------------------------
 2 Sept.1997                      KLG     Initial Code
-----------------------------------------------------------------------------------------------------
*********************************************************************************/

//Declarations:
Environment env
Integer li_RtnCode

// Turn redraw off
This.SetRedraw(False)

// Get the screen size
li_RtnCode = GetEnvironment(env)

// Move window to center of screen
li_RtnCode = This.move((PixelsToUnits(env.ScreenWidth, XPixelsToUnits!) - This.Width)/2 , &
(PixelsToUnits(env.ScreenHeight, YPixelsToUnits!) - This.Height)/2  )

// Turn redraw on
This.SetRedraw(True)

IF li_RtnCode = 1 THEN 
   Return 1 
ELSE 
   Return 0
END IF



Back to Top
© Copyright 2010, Sybase Inc.