I’m trying to create some skinned forms (just the border and caption) with a different approach than you usually see but I’m having some issues with form flickering while I resize the form.
I don’t know how else to explain the problem, so here’s a video I created to demonstrate the problem: http://www.screencast.com/t/AIqK9Szmz
Also, here’s a VS2008 test solution with the whole code that repaints the form borders:http://stuff.nazgulled.net/misc/TestForm.zip
Hope someone can help me get rid of the flicker…
(This is a Vista-specific solution; it only works when desktop compositing is enabled.)
It looks like Windows initializes the contents of resized forms by copying the pixels on the form’s original border over to the new areas. In your case, the new areas are initialized black likely because the form originally had black pixels at its border.
To get rid of the flickering, just keep the rightmost and bottommost line of pixels in the form always set to TransparencyKey — this will keep the new areas transparent until you get a chance to repaint them. I.e., make the form 1 pixel wider & taller than necessary, and paint the extra pixels transparent.
Example: TransparentForm.zip