Hello there,
I have got a problem and several approaches but none is really staisfying:
Lets assume we have a form. On its surface we have got several animations (like a blinking light).
This form is not owner drawn. Everything is drawn by child controls.
Now we want to go ahead and create an animation that is on top of everything of that form. Lets assume this animation was an arrow that is moving from the top left corner to the bottom right corner.
In order to achieve that I came by several "solutions":
- First one is probably the most obvious but least elegant one:
Get rid of all childcontrols on that form. Everything is drawn in the Paint event of the Form manually.
That works. But I dont like it as you couldnt really use win forms concept of creating forms only because of one single animation that is overlaying the whole surface.
- Second one:
The control, which is the host of that animation (e.g. this arrow) is on top of all other controls on that form and it is invisible while it is not used.
Once it is supposed to become visible you initialize it with a "screenshot" of the form. Then the controls becomes visible and as background it draws the screenshot of the form.
That works. But it only works, when there are no animations happening of the forms surface.
- Third approach:
I thought somehow it has to be possible by using a control that is really transparent. Meaning its style is set to WM_EX_TRANSPARENT by overriding its CreateParams method.
That might work but I havent got it running yet.
First problem is:
The background of my animation control is drawn fine. But once I change its location (as it is animated) the background is not redrawn.
Next problem is that I am pretty sure that backbuffering is not handled automatically.
Do you have any other better solutions to get this work?
It should be portable to .NET CF as well.
Thanks,
Kevin