If you can use 10.5 use the new CGWindowListCreateImage API.
Its a procedural C API so you can use it in C++ Carbon apps just fine. There is some sample code from Apple called "SonOfGrab" that shows how to use it, but in a Cocoa context (mostly for dealing with saving the image to a file easier).