Search code examples
delphiwindows-vistaaero

How to programmatically disable window animation under Vista Aero?


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?


Solution

  • 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);