Jump to content
  • Advertisement
Sign in to follow this  
Quat

[.net] form resize

This topic is 3925 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

When I resize my form to a larger size, my control's OnResize handler gets called. But when I resize to a smaller size, it doesn't. Anyone know why this is?

Share this post


Link to post
Share on other sites
Advertisement
It might be because the control has the AutoSizeMode set to GrowOnly instead of GrowAndShrink.

Skizz

Share this post


Link to post
Share on other sites
Thanks for the reply. I tried the GrowAndShrink, but still no luck. The control has "Fill" docking if that gives any extra clues.

Share this post


Link to post
Share on other sites
I just did a test with a RichTextBox with the Dock member set to Fill and Resize event is called when it grows and shrinks.

I think we need more information about what you are doing and how you are doing it.

theTroll

Share this post


Link to post
Share on other sites
A quick look in the .Net documentation reveals this for UserControl.OnResize:
Quote:

This method supports the .NET Framework infrastructure and is not intended to be used directly from your code.

which means it's behaviour is undefined. What you need to use is the OnSizeChanged event.

Skizz

Share this post


Link to post
Share on other sites
Quote:
Original post by Skizz
A quick look in the .Net documentation reveals this for UserControl.OnResize:
Quote:

This method supports the .NET Framework infrastructure and is not intended to be used directly from your code.

which means it's behaviour is undefined. What you need to use is the OnSizeChanged event.

Skizz


To go along with this. Many people override On_____ functions instead of subscribing to an event. Overriding a built in function should only be done if you don't want the base behavior done at all. If you just want to add functionality, the just subscribe to the event and add your own function.

theTroll

Share this post


Link to post
Share on other sites
Thanks for the replies. I switched to event handling, but it still wasn't working. I tested and was getting resize events when I shrunk down. What seems to have happened was that when I resize up, it will also invoke my paint handler, but when I resize down, it doesn't (but I want it to). So I just added an Invalidate in the resize handler and now it works as expected.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!