开发者

NSWindow Fullscreen, but show dock

开发者 https://www.devze.com 2023-03-08 22:45 出处:网络
Now I have finally managed to create a fullscreen window via http://cocoadevcentral.com/articles/000028.php

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 d开发者_运维技巧ock 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]];
}


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]];

}
0

精彩评论

暂无评论...
验证码 换一张
取 消