RE: Centering Windows

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thanks Derek,

The code you sent worked fine.

Long Live Euphoria,
Chris

-----------------------------------------------------------------
Derek Parnell wrote:
> > -----Original Message-----
> > From: president at insight-concepts.com
> > [mailto:president at insight-concepts.com]
> > Sent: Wednesday, 23 May 2001 9:25 AM
> > To: EUforum
> > Subject: Centering Windows
> > 
> > Does anyone know how to center win32lib windows no matter 
> > what the screen 
> > resolution is?
> 
> Try this procedure.
> 
> ---------------
> --/Topic Utilities
> --/proc centerWindow(integer id, integer referid)
> --/desc Moves /i id control to the center of /i refid control.
> --If /i refid is zero then the Screen is used.
> --
> --Example:
> --/code
> --       -- Move the window to the center of the screen.
> --       centreWindow( myWIN, 0)
> --       -- Move the button to the center of the window.
> --       centreWindow( myButton, myWIN)
> --/endcode
> procedure centreWindow(integer id, integer referid)
>     sequence lRect, lClient, lRefRect
>     trace(1)
>     -- use Screen if no referid supplied.
>     if referid = 0 then
>         referid = Screen
>     end if
> 
>     -- Get width and height of the window.
>     lRect = {0, 0} & getCtlSize(id)
> 
>     -- Get left, top, right, bottom co-ordinates
>     -- of the reference control client area.
>     lRefRect = getClientRect(referid)
> 
>     -- Calculate reference client area width and height
>     lRefRect[3] = lRefRect[3] - lRefRect[1]
>     lRefRect[4] = lRefRect[4] - lRefRect[2]
> 
>     -- Calculate new left and top co-ordinates
>     lRect[1] = floor((lRefRect[3] - lRect[3]) * 0.5)
>     lRect[2] = floor((lRefRect[4] - lRect[4]) * 0.5)      
> 
>     -- Move the window to the new position and repaint it.
<snip>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu