Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
i have a thin horizontal window that i want to extend from the left to right of the screen but always be, say, 20 pixels below the menu bar.

in Interface builder the coordinates start at the bottom left of the screen, and since all screens can be different size, if i use IB to position my window on my 24" iMac, it will be positioned wrong on a 20" iMac.

menubar has what, 22pixels? so how can i tell my code to find the top of the screen and move down 42 pixels?

sorry if this is a dumb question. :eek:
 

mkelly11

macrumors newbie
Dec 1, 2008
7
0
try using NSScreen

Hi there-

I remember having the exact same problem. If you're using Cocoa, try the NSScreen class (documentation here). You can use it to figure out screen dimensions and some other stuff. If you're not using Cocoa (e.g. Carbon or Java), I'm not too sure what to use, though.

Good luck!
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
Hi there-

I remember having the exact same problem. If you're using Cocoa, try the NSScreen class (documentation here). You can use it to figure out screen dimensions and some other stuff. If you're not using Cocoa (e.g. Carbon or Java), I'm not too sure what to use, though.

Good luck!

thanks mkelly11... you were right... it was necessairy to get the total size of the screen's frame and make calculations from that using NSSize and NSMakeRect... something like this:

Code:
NSSize theScreenSize = [[NSScreen mainScreen] frame].size;
[self setFrame:NSMakeRect(0, (theScreenSize.height - 50), theScreenSize.width, 25) display:YES];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.