On 28.09.2008, at 03:00, 熊佳 wrote:
Hi, All, I am a newcomer, I write a simple program on mac, and want to display the main window at the center of screen, i mean the window's position should depends on the screen's width and height, so i need to get the screen resolution, who can tell me how to get it? which api is available? Thanks James

What do you need, the resolution, or its size? Someone else has already mentioned NSWindow's center call if you really just want to center a window.

If you need the size of each screen (there may be several, which make up one huge, irregularly-shaped surface!) for something else, check out NSScreen, which was also mentioned.

As to the screen resolution, I believe there is some CGDirectDisplay API for that, or maybe there's even a Cocoa method in NSScreen, don't remember right now. However, all of these seem to rely on the screen to provide the actual resolution information in dpi, and many screens don't do this in a suitable way, it seems. One generally just gets 72 dpi back, even if the actual resolution these days is often closer to 100dpi.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to