I have tried this code to create a screenshot of an application window:
ImageEnView1.io.CaptureFromScreen(iecsForegroundWindow, -1);
ImageEnView1.io.SaveToFile('D:\window.png');
Unfortunately, part of the window frame is cut off:
You can compare it here with the same window captured with Alt+Print: