Re: Trouble centering window after mode switch
Re: Trouble centering window after mode switch
- Subject: Re: Trouble centering window after mode switch
- From: Ricky Sharp <email@hidden>
- Date: Mon, 29 Jan 2007 04:51:37 -0800
On Monday, January 29, 2007, at 02:40AM, "Matt R" <email@hidden> wrote:
>hi all cocoa gurus,
>
>Could anyone give me some advice on the following issue? I have an app that
>does the following:
>
>1) fades monitor
>2) captures display
>3) switches display modes (resolution change)
>4) sets up window in center of the screen
>5) fades out
>6) does its drawing
>7) then restores original mode, releases display, and quits
>
>
>The problem is that the code I had originally used to center the window:
>
> //window is 800x600
> screenRect = [[NSScreen mainScreen] frame];
> [splashWindow setLevel:CGShieldingWindowLevel()];
> [splashWindow setFrameTopLeftPoint:NSMakePoint( (
>screenRect.size.width/2.0)-400,
> (
>screenRect.size.height/2.0)+300)];
>
>Does not work properly and instead seems to retain its location as if the
>monitor were still at the larger resolution size (ie, the window is moved
>half offscreen to the bottom right). Funny thing is that if I switch the
>code around so that I switch display modes before capturing the screen, the
>same code as above works fine in the new resolution. The only problem with
>that code is that once I've quit my app, I find all the windows in the other
>running applications have been moved around since they adjusted their window
>locations based on the switch as well.
Are you attemping to use AppKit with a captured display? If so, that's asking for trouble. You can search the archives for reasons why not do to that (especially quartz-dev).
Anyhow, don't have links handy, but you'll want to look at the various Apple samples that capture displays and do direct drawing. Avoid the sample (I think it's on cocoa-dev) that's named slideshow example or something like that. It mixes the CG calls and AppKit.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden