Checking to see if there is a second screen present
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