473,695 Members | 1,731 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5437
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
6665
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. Here is what I've tried so far: 1. Turning off CS_VREDRAW and CS_HREDRAW in both the parent form and a subclass of the control via the "override CreateParams" property (these values were already off). 2. Setting various styles and handling...
8
5430
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 TreeView or WebBrowser control and then you resize the form. Here is what I've tried so far: 1. Turning off CS_VREDRAW and CS_HREDRAW in both the parent form and a subclass of the control via the "override CreateParams" property (these values were...
1
1714
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 change the size of this control at design time. How can I acheive that I was looking into the ImmutableObject attribute to set. But I donot have any public set property ( setters) which does set the size property. Any help is greatly appreciated.
3
3265
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 parent that holds my user control is resized, I resize my image so that it uses the maximum available space. Note: It takes about 2 seconds to regenerate the
3
4001
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 would set these properties in the overriden Size property., but I get an error message when trying this: public override Size Size { set { some code...
1
1347
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 way in the usercontrol to suppress painting during the resize? Thanks
2
7125
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
2664
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 can just capture the final event when the user has finished resizing? If it takes a relatively long time to regenerate the panel then the whole application is going to stutter. Is ClientSizeChanged the best event to capture for this or is there...
4
4186
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 Designer how do I trap the resize event so I can resize the child controls? I have tried the using: protected override void OnSizeChanged(EventArgs e) But it doesn't get called when the control is resized in the Designer.
0
8587
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9005
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6511
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4351
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4599
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3025
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2291
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.