New topic: 

Center the Window?

<http://forums.realsoftware.com/viewtopic.php?t=30583>

       Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic         Author  
Message       DrDungeon           Post subject: Center the Window?Posted: Wed 
Oct 21, 2009 11:39 am                        
Joined: Thu Jan 03, 2008 11:29 am
Posts: 60              Hi all! A quick question - If I have an app whose window 
is, say, 1680 x 1050 and run it on a Mac with that resolution, it will fill the 
whole screen. If I run it on a Mac with, say, a 1920 x 1200 resolution, it will 
appear in the upper left.

Is there a way I can center the screen? The properties options include like 
Main, Parent, Stagger, etc., but no way to default to center of screen.

I need to fuss with this as it seems Apple is going to 16:9 aspect ratios on 
the new Macs and once again I need to fuss with resolution issues.

Any tips are greatly appreciated!  -Robert   
                            Top                Steve Garman           Post 
subject: Re: Center the Window?Posted: Wed Oct 21, 2009 11:44 am                
               
Joined: Fri Sep 30, 2005 3:53 pm
Posts: 3057
Location: England              Have you tried setting the Window.Placement 
property to 2 (main screen) ?     
_________________
Steve Garman
Using REALbasic 2008r2 Professional on Windows Vista Ultimate
and REALbasic 2009r4 Professional on Linux Ubuntu 9.04 Desktop
Occasional blog  
                            Top               DaveS           Post subject: Re: 
Center the Window?Posted: Wed Oct 21, 2009 11:57 am                             
  
Joined: Sun Aug 05, 2007 10:46 am
Posts: 1670
Location: San Diego, CA              how about this

window1.left=(screen(0).width-window1.width)/2
window1.top=(screen(0).height-window1.height)/2     
_________________
Dave Sisemore
MacPro, OSX 10.5.8 RB2009r2  
                            Top               Phil M           Post subject: 
Re: Center the Window?Posted: Wed Oct 21, 2009 1:07 pm                        
Joined: Fri Sep 30, 2005 12:18 pm
Posts: 177              use this code so you don't run into MenuBars / Dock / 
System Trays, StartBar, etc...
Code:Window1.Left = Screen( 0 ).AvailableLeft + (( Screen( 0 ).AvailableWidth - 
Window1.Width ) / 2 )
Window1.Top = Screen( 0 ).AvailableTop + (( Screen( 0 ).AvailableHeight - 
Window1.Height ) / 2 )

If ( Window1.Left < Screen( 0 ).AvailableLeft ) Or ( Window1.Top < Screen( 0 
).AvailableTop ) Then
  // oops!  window is too big for the available area... what to do... what to do
End If
   
                            Top           Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 posts ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to