• 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
Re: How can I display a window to the second screen if there are multiple screens?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I display a window to the second screen if there are multiple screens?


  • Subject: Re: How can I display a window to the second screen if there are multiple screens?
  • From: Matt Neuburg <email@hidden>
  • Date: Fri, 16 Aug 2002 20:42:02 -0700

On Fri, 16 Aug 2002 01:15:15 +0200, Marc Liyanage <email@hidden> said:

>I want to pop up several windows, one per attached screen on the
>machine.
>However, for other reasons I decided to create the windows from a .nib
>file instead of programmatically.
>The problem I seem to have now is that I cannot position a window onto
>the second screen.
>
>I am reading out screen coordinates with CGGetActiveDisplayList() and
>CGDisplayBounds()

Why?

>I then tried to use these to calculate the positions for the two
>windows, but they always end up on the main screen

Uncheck "deferred" in IB. The following works OMM:

- (void) awakeFromNib {
NSArray* screens = [NSScreen screens];
NSRect s1 = [[screens objectAtIndex: 0] frame];
NSRect s2 = [[screens objectAtIndex: 1] frame];
float s1x = (s1.size.width - [window1 frame].size.width)/2;
float s1y = (s1.size.height - [window1 frame].size.height)/2;
float s2x = (s2.size.width - [window2 frame].size.width)/2;
float s2y = (s2.size.height - [window2 frame].size.height)/2;
[window1 setFrameOrigin: NSMakePoint (s1.origin.x+s1x, s1.origin.y+s1y)];
[window2 setFrameOrigin: NSMakePoint (s2.origin.x+s2x, s2.origin.y+s2y)];
[window1 makeKeyAndOrderFront: self];
[window2 makeKeyAndOrderFront: self];
}

m.
--

matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: How can I display a window to the second screen if there are multiple screens?
      • From: Marc Liyanage <email@hidden>
  • Prev by Date: Re: Detect "delete" in text field
  • Next by Date: NSTextFieldCell & editWithFrame
  • Previous by thread: Re: Detect "delete" in text field
  • Next by thread: Re: How can I display a window to the second screen if there are multiple screens?
  • Index(es):
    • Date
    • Thread