Resize control during OnSizeChanged

  • Thread starter Thread starter Mark Ingram
  • Start date Start date
M

Mark Ingram

Hi, ive got a custom control, which i like to keep at a fixed size (or a
fixed ratio). So, during the OnSizeChanged function, i specify values
for width and height. Which in *some* cases (i dont know why only some
cases) results in stack overflow because changing the height results in
OnSizeChanged being called again.



What is the correct way of altering the size of the control after a user
has changed the controls size?

Thanks
 
Mark said:
Hi, ive got a custom control, which i like to keep at a fixed size (or a
fixed ratio). So, during the OnSizeChanged function, i specify values
for width and height. Which in *some* cases (i dont know why only some
cases) results in stack overflow because changing the height results in
OnSizeChanged being called again.



What is the correct way of altering the size of the control after a user
has changed the controls size?

Thanks

How I usually do this is to handle the resize event. I remove the
handler at the start of the event, and then make my change. Then I add
the handler back in. This way I avoid any & all recursive calls.

Hope it helps
Chris
 
Chris said:
How I usually do this is to handle the resize event. I remove the
handler at the start of the event, and then make my change. Then I add
the handler back in. This way I avoid any & all recursive calls.

Hope it helps
Chris

OK thanks, worth considering. I find it strange why it works some times
and not all the time!

The only problem i can see is that we're supposed to be using
OnSizeChanged / OnResize, instead of using events.

Thanks
 

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

Back
Top