• 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
Move window to second display
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Move window to second display


  • Subject: Move window to second display
  • From: Fabian <email@hidden>
  • Date: Wed, 16 Jul 2008 13:01:08 +0200

Hi,

I only have one monitor, so I'm having a bit of a problem figuring this out.

I have a (borderless) window that should be displayed on any display
chosen by the user. I figured the code below would do the trick, but
apparently it's a no go (I use setFrameFromString: when the app is
launched; this is when settings are changed during runtime):

NSRect screenRect = [[NSScreen mainScreen] frame];
NSArray *screens = [NSScreen screens];
int preferredDisplay =  [[[NSUserDefaults  standardUserDefaults]
objectForKey:@"PreferredDisplayID"] intValue];

for (id screen in screens ) {
		CGDirectDisplayID display = (CGDirectDisplayID) [[[screen
deviceDescription] valueForKey:@"NSScreenNumber"] unsignedIntValue];
		if ( preferredDisplay == display ) {
			screenRect = [screen frame];
			break;
		}
}

[win setFrame:screenRect display:YES];


Please advice.

Thanks
F.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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: Move window to second display
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Converting Windows RC to NIBs (was Re: Creating and App menu from Scratch)
  • Next by Date: Re: Move window to second display
  • Previous by thread: Re: Text selection in NSTableView
  • Next by thread: Re: Move window to second display
  • Index(es):
    • Date
    • Thread