【发布时间】:2011-01-04 10:24:30
【问题描述】:
我有以下代码,除了我永远看不到我创建的myWindow 之外,这些代码大部分都可以工作。如果我这样做[myWindow isVisible],它会返回1。 CGDisplayCapture 工作正常,因为它使屏幕空白。我已经检查了我传递给 NSWindow init 方法的所有变量。
我是否遗漏了一些非常明显的东西?代码如下:
// Find the screen we want
NSScreen *screen = [[NSScreen screens] objectAtIndex:1];
NSNumber *displayID = [[screen deviceDescription]
objectForKey:@"NSScreenNumber"];
CGDirectDisplayID CGDisplayID = (CGDirectDisplayID) [displayID intValue];
// Capture the secondary display
if (CGDisplayCapture( CGDisplayID ) != kCGErrorSuccess) {
NSLog( @"Couldn't capture the secondary display" );
}
// Draw a new window to fill the screen
NSRect screenRect = [screen frame];
NSWindow *myWindow = [[NSWindow alloc] initWithContentRect:screenRect
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO
screen:screen];
// Set the level of the new window and other settings
NSInteger windowLevel = CGShieldingWindowLevel();
[myWindow setLevel: windowLevel];
[myWindow setBackgroundColor:[NSColor blueColor]];
[myWindow makeKeyAndOrderFront:nil];
干杯
【问题讨论】:
标签: cocoa fullscreen nswindow