471,627 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

drawing

How to make this:

I have a panel and I draw something on it (some lines, a complex
function...).
I want this:
When I move mouse over that panel to draw a vertical line from top of the
panel to panel.height on the X position of the mouse? While I'm moving a
mouse over a panel that vertical line is moving too aloong with the mouse
cursor.
Do I have to redraw a whole panel for every mouse movement??? That's not a
good idea, ist' VERY slow...

any suggestions, PLEASE??
thanks!
Feb 19 '06 #1
2 1489
I have a few ideas, but am not totally sure if it will help solve your
problem...

First suggestion: By calling the Panel's Invalidate method, you can
specificy the region that needs to be repainted via the use of the
Rectangle Struct. This should only redraw part of the Panel rather
than the entire thing.

Another option is to set the style used on the Form. When I've had to
do quick animations in .NET without using DirectX, I've managed to
solve a lot of my problems with this approach (it can get rid of
annoying flickering that can happen when your drawing requires a lot of
repainting/refreshing).

Here's a link to what MSDN has to say about it:

http://msdn.microsoft.com/library/de...classtopic.asp

Here's the bit of code that I found to be the most useful when dealing
with any sort of animation:

public class Form1: System.Windows.Forms.Form
{
public Form1()
{
SetStyle( ControlStyles.UserPaint, true );
SetStyle( ControlStyles.AllPaintingInWmPaint, true );
SetStyle( ControlStyles.DoubleBuffer, true );
}
}

These SetStyle calls (all three of these together) will turn on double
buffering for your form and should make things run a bit faster.

Hope this helps...

-- Dan

Feb 20 '06 #2
Dnia 19-02-2006 o 18:18:02 Bad_Kid <RE*******************@yahoo.co.uk>
napisał:
How to make this:

I have a panel and I draw something on it (some lines, a complex
function...).
I want this:
When I move mouse over that panel to draw a vertical line from top of the
panel to panel.height on the X position of the mouse? While I'm moving a
mouse over a panel that vertical line is moving too aloong with the mouse
cursor.
Do I have to redraw a whole panel for every mouse movement??? That's not
a
good idea, ist' VERY slow...

any suggestions, PLEASE??
thanks!

[PD] You can invalidate only parts of the control when you move the mouse.
Look at the different overloads of the Control.Invalidate method.

--
Piotr Dobrowolski
Piotr.Dobrowolski@_usun_gmail.com
Feb 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Tomi Holger Engdahl | last post: by
2 posts views Thread by Champika Nirosh | last post: by
7 posts views Thread by Marc Pelletier | last post: by
3 posts views Thread by Chris Saunders | last post: by
2 posts views Thread by ThatsIT.net.au | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.