Re: Checking to see if there is a second screen present
Re: Checking to see if there is a second screen present
- Subject: Re: Checking to see if there is a second screen present
- From: Mike Abdullah <email@hidden>
- Date: Fri, 10 Nov 2006 17:47:12 +0000
I may be missing something obvious here (I've never really worked
with NSScreen), but can't you just do:
[[NSScreen screens] count]
to find out how many screens there are?
Mike.
On 10 Nov 2006, at 17:28, Adam Radestock wrote:
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:
40gmail.com
This email sent to email@hidden
_______________________________________________
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