473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 5414
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ian Stiles | last post by:
I have tried everything under the sun to get rid of horrible flashing and flickering that occurs on a CSharp form when the form hosts a TreeView or WebBrowser control and then you resize the form....
8
by: Ian Stiles | last post by:
If you have "Show window contents while dragging" turned on (Right-click desktop, Appearance, Effects) then you get horrible flashing and flickering on a CSharp form when the form hosts a...
1
by: Suresh | last post by:
I am trying to create a composite control which is essentially a panel with 4 labels and 4 check boxes I have designed the control in VisualStudio form designer. I dont want to allow the user to...
3
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the...
3
by: ORC | last post by:
How do I override the Size property in a user made Control (e.g.: public void Graph : Control). I'll need to set gridsize etc. that is dependent of the control size and therefore I thought that I...
1
by: **Developer** | last post by:
I'm geting a lot of flashing while resizing a form containing one of my usercontrols that is docked fill. This doesn't alway happen, depends on what is visible on the control. Is there some...
2
by: Dom | last post by:
What is the difference between these two events? Help says one occurs when the Size property changes, and the other occurs when the control is resized. Isn't that the same thing?
1
by: steve | last post by:
I have a form with a toolstrip, a panel and a status bar. On the panel I added an event handler for ClientSizeChanged but it calls the handler umpteen times during a resize. Is there any way that I...
4
by: Stewart Berman | last post by:
I have a compound custom control derived from UserControl. It has three controls on it -- two custom controls and a Label control. When the control is added to a from and then resized using the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.