Help needed: Window snapshot function


#1

I need to write a function that allows snapshotting (creating an Image of) some window (not necessarily a JUCE one) on the screen.
It must for 64 Bit apps, and work on 10.7, too. If anyone can help me out, I’d be eternally thankful. I have spent the whole day on it and didn’t come up with anything useful.


#2

Did Son of Grab not work?
http://developer.apple.com/library/mac/#samplecode/SonOfGrab/Introduction/Intro.html


#3

I tried it, it works. However I’ve never coded Obj-C nor Cocoa. There’s a thing I don’t understand: I use pluginEditor->getPeer()->getNativeHandle() to retrieve the handle to the VST window. How do I get a CGWindowID from this?

Edit: It seems this is a NSView* that JUCE is returning, for which I then retrieve the window handle with the window member of NSView, then accessing windowNumber. But that isn’t the right CGWindowID, as there still seems to be an added Carbon Window where the VST is put onto. Have to dig deeper…

Jules, is there an easy way to determine the window id, considering that it all depends on if the plugin has a carbon view or not?