views:

1980

answers:

2

I'm working on a Cocoa Mac app where I need to display a window/view on a secondary monitor, full-screen. I know how to create a window that could be dragged onto the secondary monitor, but I was wanting to programatically create the window and make it full screen on the external monitor. Thanks for the help.

+4  A: 

First, determine which screen you want to use by iterating over [NSScreen screens].

Create a full screen window with:

NSScreen *screen = /* from [NSScreen screens] */
NSRect screenRect = [screen frame];
NSWindow *window = [[NSWindow alloc] initWithContentRect:screenRect
    styleMask:NSBorderlessWindowMask
    backing:NSBackingStoreBuffered
    defer:NO
    screen:screen];
[window setLevel: CGShieldingWindowLevel()];

You might want to google CGDisplayCapture() as well.

sbooth
Thank you, that worked great. Since I was trying to output to the secondary screen I just used [window setLevel: NSStatusWindowLevel];
Austin
+4  A: 
e.James
Thank you for the help. For what I was trying to do I think the first solution is going to work best for me, but I'll have to keep that View full screen method in mind.
Austin