views:

655

answers:

3

My application does automated screenshots of several dynamically created forms. This works perfectly under Windows XP, but doesn't work well under Vista Aero. Most of the forms appear semitransparent in the screenshots. The problem lies in the window animation of Aero.

How can I check/disable/enable this animation from inside a Delphi (2007+) program?

Or as an alternative: How can I make sure the form is displayed properly before making the screenshot?

A: 

You can add a manifest resource to the exe file, to notify Vista you want that the application runs without Aero http://www.google.be/search?q=vista+manifest+resource+delphi

Stijn Sanders
+1  A: 

Disabling Aero would be a pity - in general it's not a good idea to change the user's choice of UI style.

You may be able to draw the form another way. One thing that comes to mind is using the PaintTo method to paint it to a canvas. (In fact, if you're taking screenshots of the forms as a way of getting what it looks like you probably don't need to show the forms at all - created them with Visible set to false and paint them to a bitmap. Only show them if the user needs to interact with them.)

David M
The screenshots are taken during an automated build. So the user won't bother at all.But the idea using PaintTo sounds interesting...
Uwe Raabe
A: 

The link in the comment from Shoban led me in the right direction. A quick check showed a wrapper for the DwmApi in the VCL and from that it went straight forward. Here is the code I successfully use now:

uses DwmApi;
...
  SaveDwmCompositionEnabled := DwmCompositionEnabled;
  if SaveDwmCompositionEnabled then
    DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
...
  if SaveDwmCompositionEnabled then
    DwmEnableComposition(DWM_EC_ENABLECOMPOSITION);
Uwe Raabe
i really don't like this solution; disabling Desktop Composition isn't something i would want anyone else who finds this question to do. i assume the animation time is configurable in the system, but assume it's 200ms. Start a 200ms timer during OnShow to take a screenshot then. If the timer is still running when OnClose fires, then take a screenshot then.
Ian Boyd
That is indeed a possibility. Althoug, I wouldn't do it in my case as it would increase the time used a lot, just because of the shear number od the screenshots to take.But at least it is an option.
Uwe Raabe