Re: Move window to second display
Re: Move window to second display
- Subject: Re: Move window to second display
- From: Fabian <email@hidden>
- Date: Wed, 16 Jul 2008 13:39:09 +0200
Thanks Jean-Daniel, I will try that.
F.
On Wed, Jul 16, 2008 at 1:21 PM, Jean-Daniel Dupas
<email@hidden> wrote:
>
> Le 16 juil. 08 à 13:01, Fabian a écrit :
>
>> 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.
>
> The screen frame origin represent the screen position relative to the whole
> space. (a point relative to the main screen origin (the one with the menu
> bar)).
>
> The window frame origin is a position relative to the screen origin.
>
> Try this:
>
> screenRect.origin = NSZeroPoint;
> [win setFrame:screenRect display:YES];
>
>
>
_______________________________________________
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