• 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: Moving a window offscreen
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Moving a window offscreen


  • Subject: Re: Moving a window offscreen
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sat, 7 Mar 2009 13:00:06 +0100


Le 7 mars 09 à 12:25, Jonathan Dann a écrit :


On 7 Mar 2009, at 12:20, Jean-Daniel Dupas wrote:


Le 7 mars 09 à 12:11, Jonathan Dann a écrit :

On 7 Mar 2009, at 10:20, Jean-Daniel Dupas wrote:


Le 7 mars 09 à 05:50, Michael Ash a écrit :

On Fri, Mar 6, 2009 at 1:38 PM, Jonathan Dann <email@hidden> wrote:
Hi All,

In my application I want to create an image of a document window as a
preview prior to displaying the window to the user. To obtain the CGImage of
a displayed window is simple enough using the CGWindow API as shown below:


- (CGImageRef)CGImage;
{
   return CGWindowListCreateImage(CGRectNull,
kCGWindowListOptionIncludingWindow, [self windowNumber],
kCGWindowImageDefault);
}

The problem comes when trying to display the window initially at a far-off
position so I can create the image and the move the window onto the screen.


Setting the origin of the window to a point with large +ve or - ve ordinates
causes the window to appear at the edge of the main screen, partly shown.


Has anybody any experience with either a) rendering an entire window into a
bitmap instead of to the screen, or b) moving the window offscreen
completely? If b) is possible, would the above code work for such a window?

If you create the window with the "defer" flag set to NO, then the
NSWindow object will get a window server window even when it's not
actually ordered onto the screen. I *believe* that you will then be
able to capture it without ever displaying it so that it's visible to
the user, simply by not sending it an orderFront: or any similar
message.


As an alternative, use -dataWithPDFInsideRect: to generate an image.
This technique tends to be rather slow, though.



Has this technic some benefit over locking focus on the window content view and using - [NSBitmapImageRep initWithFocusedViewRect:] ?


If I locked focus on the content view, I'm not sure I'd get the title bar too. Am I wrong in thinking this?

Thanks for your time,

Jonathan

No, you won't. That's the draw back, but my question was more about the pro of using dataWithPDFInsideRect: to generate an image instead of [NSBitmapImageRep initWithFocusedViewRect:].

I get you, for me I need to then draw the window image into a CALayer, so I'd have to create a CGImage from the PDF data.

Just for the record, NSBitmapDataRef has a - CGImage method which returns a CGImageRef.



_______________________________________________

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: Moving a window offscreen
      • From: Kyle Sluder <email@hidden>
References: 
 >Moving a window offscreen (From: Jonathan Dann <email@hidden>)
 >Re: Moving a window offscreen (From: Michael Ash <email@hidden>)
 >Re: Moving a window offscreen (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Moving a window offscreen (From: Jonathan Dann <email@hidden>)
 >Re: Moving a window offscreen (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Moving a window offscreen (From: Jonathan Dann <email@hidden>)

  • Prev by Date: Re: Moving a window offscreen
  • Next by Date: Re: Setting 'is package' bit when building a plug-in bundle?
  • Previous by thread: Re: Moving a window offscreen
  • Next by thread: Re: Moving a window offscreen
  • Index(es):
    • Date
    • Thread