Jump to content
  • Advertisement
Sign in to follow this  
acid2

[.net] Making .NET redraw the whole control

This topic is 4808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, Im developing my own custom control that is similar to the Automator flow graph in Apple Mac OSX Tiger. I have my custom control, and a check box on that. When I click the checkbox, I need it to redraw the whole custom control. The current way im drawing is by overriding OnPaint. However, if I click the checkbox it only redraws the custom control in that portion. Any ideas on how I can make it redraw everything?

Share this post


Link to post
Share on other sites
Advertisement
In Win32, the system maintains lists of what is dirty (i.e. has to repainted), and clips your drawing against it.

If you want to redraw the whole control, you just have to tell Windows that it needs repainting. To do that, you "invalidate" your control. Call:
myControl.Invalidate();

When you click the checkbox, it only invalidates the checkbox, not the whole control. Because Windows is lazy and always try to paint the less possible (which is good practice, try to do it also. Invalidate may also take a dirty rectangle).

You don't need to call OnPaint directly, Windows will do it for you when something is invalidated. Overriding OnPaint is the way to go to do the custom drawing.

Hope I'm clear,
jods

Share this post


Link to post
Share on other sites
Yea, I know about custom drawing - the control is customly drawn. Here are 2 pictures illustrating the problem. Look at the 2nd round box.

What it currently looks like:

The box is dark because the check box was unticked (meaning its disabled). When the checkbox is ticked, everything should be redrawn - resulting in this image:



The only way to get to the second image though, is to create a new box, delete a box, minimize the window, etc.

Any ideas?

Share this post


Link to post
Share on other sites
I will repeat what I said in my previous post:
when the checkbox change (tick/untick), call roundBox.Invalidate().
If it doesn't repaint correctly, then maybe your painting code is wrong.

If you still have problems, could you post your code for:
1. the CheckedChanged event, and
2. the round box OnPaint method.

By the way, your control looks great! And what is the docking control you're using ? Is it the one from divil.co.uk ?

Share this post


Link to post
Share on other sites
Ya, gotta it working by requesting an entire redraw. Sorry about the misunderstanding :)

Thank you for your compliments on my control - I will have a video demonstrating both of the controls working in unison soon. Any yea, thats the SandDock control.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!