• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Checking to see if there is a second screen present
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking to see if there is a second screen present


  • Subject: Checking to see if there is a second screen present
  • From: Adam Radestock <email@hidden>
  • Date: Fri, 10 Nov 2006 17:28:17 +0000

How do I check to see if there is a second screen without throwing an exception if there isn't?

Currently my code is as follows: -

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
int windowLevel;
NSRect screenRect;

NSScreen* myQCScreen = [[NSScreen screens] objectAtIndex:1];
if (myQCScreen != nil) {
NSDictionary* screenInfo = [myQCScreen deviceDescription];
NSNumber* screenID = [screenInfo objectForKey:@"NSScreenNumber"];
CGDirectDisplayID displayID = (CGDirectDisplayID)[screenID longValue];

// Capture the second display
if (CGDisplayCapture(displayID) != kCGErrorSuccess) {
NSLog(@"Couldn't capture the display...");
}

// Get the shielding window level
windowLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey);
// Get the screen rect of our live display
screenRect = [myQCScreen frame];

// Put up a new window
renderWindow = [[NSWindow alloc] initWithContentRect:screenRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO screen:[NSScreen mainScreen]];

[renderWindow setLevel:windowLevel];
[renderWindow setBackgroundColor:[NSColor blackColor]];
[renderWindow makeKeyAndOrderFront:nil];

// Load our content view
[myPanel setFrame:screenRect display:YES];
[renderWindow setContentView:[myPanel contentView]];
}
else {
NSLog(@"Second display not connected!");
[self displayMessage:@"Second display not connected!" description:@"Working in offline mode. You will need to restart ScreenRunner VJ after connecting the second display." withIcon:YES];
}

if(_filePath == nil) {
[self setDefaultPatch:nil];
}
else {
[self setLivePatch:_filePath];
}

[libraryController setupPatchLibrary];
[libraryTableView reloadData];
}


I'm new(ish) to Cocoa, and can't work this one out...

Thanks for your help,

Adam Radestock
Glass Monkey Design Co.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Checking to see if there is a second screen present
      • From: leenoori <email@hidden>
    • Re: Checking to see if there is a second screen present
      • From: Mike Abdullah <email@hidden>
    • Re: Checking to see if there is a second screen present
      • From: Nick Zitzmann <email@hidden>
  • Prev by Date: Re: Re: newbie question
  • Next by Date: Re: Checking to see if there is a second screen present
  • Previous by thread: [Moderator] List guidelines and related resources (updated)
  • Next by thread: Re: Checking to see if there is a second screen present
  • Index(es):
    • Date
    • Thread