471,354 Members | 1,509 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Resize control during OnSizeChanged

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
Feb 20 '06 #1
2 5289
Mark Ingram wrote:
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
Feb 20 '06 #2
Chris wrote:
Mark Ingram wrote:
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


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
Feb 21 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Ian Stiles | last post: by
1 post views Thread by Suresh | last post: by
3 posts views Thread by Z D | last post: by
2 posts views Thread by Dom | 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.