• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Trouble centering window after mode switch
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trouble centering window after mode switch


  • Subject: Trouble centering window after mode switch
  • From: "Matt R" <email@hidden>
  • Date: Mon, 29 Jan 2007 00:39:08 -0800

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.

To simplify: I'm having difficulty pinpointing how/when to adjust my window
properly. If I capture the display first before switching modes, and try to
center my window, it's almost as if I never switched at all, and I can't
seem to center the window properly. Doing the opposite, and switching modes
before capturing the display, allows me to use the same code as above and
the window is perfectly centered, but all my other apps on the system get
their window locations screwed up.

I'm sorry if I'm overlooking the obvious. I've been trying to squash this
bug for about 10 days, just can't figure out what I'm missing.

Any help or advice is much appreciated. thank you for your time.
-matt
_______________________________________________

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


  • Follow-Ups:
    • Re: Trouble centering window after mode switch
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: Flipping Text
  • Next by Date: Re: MenuStatusItem --
  • Previous by thread: Re: Flipping Text
  • Next by thread: Re: Trouble centering window after mode switch
  • Index(es):
    • Date
    • Thread