NSWindow 全屏,但显示停靠栏

发布于 2024-11-10 01:54:52 字数 1392 浏览 2 评论 0原文

现在我终于设法通过 http://cocoadevcentral.com/articles/000028.php< 创建一个全屏窗口/a> 精彩的教程。现在的问题是如何使用以下代码来显示停靠栏和菜单栏,因为目前我有一个完全黑的屏幕,我想看到菜单栏和停靠栏。这可能吗?

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
     int windowLevel;
     NSRect screenRect;
     // Capture the main display
     if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
         NSLog( @"Couldn't capture the main display!" );
         // Note: you'll probably want to display a proper error dialog here
     }
     // Get the shielding window level
     windowLevel = CGShieldingWindowLevel();
     // Get the screen rect of our main display
     screenRect = [[NSScreen mainScreen] frame];
     // Put up a new window
     mainWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                    styleMask:NSBorderlessWindowMask
                                    backing:NSBackingStoreBuffered
                                    defer:NO screen:[NSScreen mainScreen]];
     [mainWindow setLevel:windowLevel];
     [mainWindow setBackgroundColor:[NSColor blackColor]];
     [mainWindow makeKeyAndOrderFront:nil];
     // Load our content view
     [slideShowPanel setFrame:screenRect display:YES];
     [mainWindow setContentView:[slideShowPanel contentView]];
}

Now I have finally managed to create a fullscreen window via http://cocoadevcentral.com/articles/000028.php
Brilliant tutorial. Now the question how do I use the following code to show the dock and menubar, as currently I have a completely black screen, I would like to see a menubar and a dock. Is that possible?

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
     int windowLevel;
     NSRect screenRect;
     // Capture the main display
     if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
         NSLog( @"Couldn't capture the main display!" );
         // Note: you'll probably want to display a proper error dialog here
     }
     // Get the shielding window level
     windowLevel = CGShieldingWindowLevel();
     // Get the screen rect of our main display
     screenRect = [[NSScreen mainScreen] frame];
     // Put up a new window
     mainWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                    styleMask:NSBorderlessWindowMask
                                    backing:NSBackingStoreBuffered
                                    defer:NO screen:[NSScreen mainScreen]];
     [mainWindow setLevel:windowLevel];
     [mainWindow setBackgroundColor:[NSColor blackColor]];
     [mainWindow makeKeyAndOrderFront:nil];
     // Load our content view
     [slideShowPanel setFrame:screenRect display:YES];
     [mainWindow setContentView:[slideShowPanel contentView]];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野却迷人 2024-11-17 01:54:52

我做了一些实验,但我想通了;

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
int windowLevel;
NSRect screenRect;
// Capture the main display

// Get the screen rect of our main display
screenRect = [[NSScreen mainScreen] frame];
// Put up a new window
mainWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                         styleMask:NSBorderlessWindowMask
                                           backing:NSBackingStoreBuffered
                                             defer:NO screen:[NSScreen mainScreen]];
[mainWindow setLevel:windowLevel];
[mainWindow setBackgroundColor:[NSColor blackColor]];
[mainWindow makeKeyAndOrderFront:nil];
// Load our content view
[slideShowPanel setFrame:screenRect display:YES];
[mainWindow setContentView:[slideShowPanel contentView]];

}

Took a bit of experimenting but I figured it out;

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
int windowLevel;
NSRect screenRect;
// Capture the main display

// Get the screen rect of our main display
screenRect = [[NSScreen mainScreen] frame];
// Put up a new window
mainWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                         styleMask:NSBorderlessWindowMask
                                           backing:NSBackingStoreBuffered
                                             defer:NO screen:[NSScreen mainScreen]];
[mainWindow setLevel:windowLevel];
[mainWindow setBackgroundColor:[NSColor blackColor]];
[mainWindow makeKeyAndOrderFront:nil];
// Load our content view
[slideShowPanel setFrame:screenRect display:YES];
[mainWindow setContentView:[slideShowPanel contentView]];

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文