How to make a transition effect between two forms?

G

Guest

Hi!

I want to create an appealing user interface by using transitions when
passing form a form to another. For instance, I want to create an ipod-like
effect, where forms are appearing by sliding from the right side of the
screen.


In order to do it, I though the best way would be to capture the form to
appear into a Bitmap, and then animate that bitmap from right to left.

I have used a sample from MSDN to capture the form to a Bitmap
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/scibf.asp

The problem is that the captured bitmap does not contain the form. Controls
on top of the form are not painted, and appear as empty rectangles.

Do you know how it is possible to paint a form (including all the controls
into that form) into a Bitmap object?

The challenge here, is that the form to capture is not currently displayed.

Your help will be really appreciated!
Thanks a lot!


This is the code for the form to appear with a right-left transition:

protected override void OnPaint(PaintEventArgs e)
{
if (animate)
{
Bitmap bmp = BitmapFile.CaptureControl(this, 24,
this.Bounds.Width, this.Bounds.Height);

Graphics graphics = this.CreateGraphics();
for (int i = this.Bounds.Width; i > 0; i = i - 1)
{
graphics.DrawImage(bmp, i, 0);

Thread.Sleep(10);
}

bmp.Dispose();

animate = false;

this.Refresh();
}
else
{
base.OnPaint(e);
}
}
 
G

Guest

Thanks a lot. FlowFX is pretty amazing.

However, it is not perfect yet. It suffers from the same problem I was
trying to solve: to get a bitmap of a form which is not currently displayed.

If you observe FlowFX carefully, you see that a white form is used for the
transitions. The controls on the "destination" form are painted when the
transition is over. I have looked at the code, and it is not capturing the
"destination" form into a bitmap, but it either use a copy of the origin
form, or a blank one.

So, in order to perfect the transitions, we must be able to display a form
into a bitmap, or an off screen buffer. I have looked everywhere, but I can't
find a way to do it.

How could we trigger the OnPaint event of a form and pass a custom
"PaintEventArgs" parameter with a "Graphics" targetting a bitmap, rather than
the current display ??
If it's impossible, is there any other way?
I heard there are new possiblities for custom controls, and user-drawn
controls in Windows Mobile 6.0, do you know if it would help?

Thanks a lot. Your support is greatly appreciated!!

Lionel

Here is a piece of code which shows how we could trigger a Paint event on a
form and pass a custom PaintEventArgs object. Unfortunately, it does not work
that way, as it seems Paint events can only be triggered from within the
Control.

Bitmap bitmap = new Bitmap(form2.Bounds.Width,
form2.Bounds.Height);
Graphics graphics = Graphics.FromImage(bitmap);

PaintEventArgs e = new PaintEventArgs(graphics, new
Rectangle(form2.Bounds.X, form2.Bounds.Y, form2.Bounds.Width,
form2.Bounds.Height));
form2.Paint(e);
 
G

Guest

I believe that the short answer is that you can't. GWES/GDI is handling the
painting, and the only way you could possibly get a capture of the next app
"down" would be to somehow get it to paint off-screen (so find out who it
is, move it's window position, capture that area of the framebuffer, then
move it back. Of course that assumes that the display driver doesn't just
toss the off-screen data (which I would if I were writing the driver).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top