views:

269

answers:

0

After experimenting with screenshots of programmatically sized Outlook Inspectors, I've noticed that resizing is not instant. (TakeScreenshot is done programaticcaly by creating a bitmap from the window's device context, then writing it to disk.

  • Version A: Resize, Bringtofront, TakeScreenshot
  • Version B:Resize, Bringtofront, threadsleep(1sec), takescreenshot
  • Version C:Resize, Bringtofront, keep calling doevents for 1s, TakeScreenshot
  • Version D:Resize, Bringtofront, msgbox "foo", takescreenshot.

The only one which takes screenshots correctly is D. In all other cases, some elements of the window don't seem to be loaded.

What is going on here? How can I ensure that the window loaded completely before taking the screenshot. I tried using timers, but it tended to have exceptions.