473,396 Members | 2,129 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,396 software developers and data experts.

Need to fire event AFTER a control is resized.

I have a control that the user is able to manually resize --- and it works
great. The problem is I need to handle something when the control is done
being resized, but not during the resize, so just putting what I need in the
resize event won't work. If it matters, the control is hosted on a
DesignSurface (system.componentmodel.design.DesignSurface).
Jun 3 '06 #1
4 1773
Hi mfielder,

Thanks for your post!

In .Net Winform2.0, there is a new Form.ResizeEnd exposed, which is fired
when we finished resizing the Form. This event internally encapsulates
Win32 WM_EXITSIZEMOVE message. For more information, please refer to my
original thread below:
http://groups.google.com/group/micro...es.csharp/brow
se_thread/thread/f77a4f68c9944e89/40a4dc2ea543405a?lnk=st&q=%22Jeffrey+Tan%2
2+resize+resizeend&rnum=1&hl=zh-CN#40a4dc2ea543405a
Note: please take care of the link-break in the URL.

However, in your DesignSurface scenario, I think this is not what you want:
1. This event only exposes to the Form class.
2. DesignSurface provided the control design-time manipulation feature with
..Net winform code internally, it does not fire WM_EXITSIZEMOVE message even
to the Form class. I suspect it programmatically changes the Form/Controls
size internally.

So we can not use these runtime technologies to your design-time
application. I think we have to resort to the designer object model to get
the notification. What I can think of is getting IComponentChangeService
interface in the designer, then handling ComponentChanged event. There are
2 parameters we are interested in this event:
1. Component: we can use it to determine which component/control is
currently changed.
2. Member: we should monitor the "Size" property member

With monitoring these 2 parameters in the event, we determine it is "Size"
property that is changed just now. However, this requires some extra work
to be done.

Finally, you'd better post in .Net winform newsgroups for such issue.
Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '06 #2
First off, I appologize for posting in the wrong group -- I'm new around
here. Is there a simple way to move this thread to the correct group?

On to the problem - I think that we're really headed in the right direction
- it looks like the interface mentioned is designed exactly with what I'm
trying to do in mind. The problem now is that I've added the interface to my
implementation of designsurface, but it doesn't appear that the events are
actaully firing. I can post the class if that helps, but not sure how to do
that.

""Jeffrey Tan[MSFT]"" wrote:
Hi mfielder,

Thanks for your post!

In .Net Winform2.0, there is a new Form.ResizeEnd exposed, which is fired
when we finished resizing the Form. This event internally encapsulates
Win32 WM_EXITSIZEMOVE message. For more information, please refer to my
original thread below:
http://groups.google.com/group/micro...es.csharp/brow
se_thread/thread/f77a4f68c9944e89/40a4dc2ea543405a?lnk=st&q=%22Jeffrey+Tan%2
2+resize+resizeend&rnum=1&hl=zh-CN#40a4dc2ea543405a
Note: please take care of the link-break in the URL.

However, in your DesignSurface scenario, I think this is not what you want:
1. This event only exposes to the Form class.
2. DesignSurface provided the control design-time manipulation feature with
.Net winform code internally, it does not fire WM_EXITSIZEMOVE message even
to the Form class. I suspect it programmatically changes the Form/Controls
size internally.

So we can not use these runtime technologies to your design-time
application. I think we have to resort to the designer object model to get
the notification. What I can think of is getting IComponentChangeService
interface in the designer, then handling ComponentChanged event. There are
2 parameters we are interested in this event:
1. Component: we can use it to determine which component/control is
currently changed.
2. Member: we should monitor the "Size" property member

With monitoring these 2 parameters in the event, we determine it is "Size"
property that is changed just now. However, this requires some extra work
to be done.

Finally, you'd better post in .Net winform newsgroups for such issue.
Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '06 #3
That was exactly what I needed. Thanks.

""Jeffrey Tan[MSFT]"" wrote:
Hi mfielder,

Thanks for your feedback!

Based on my knowledge, DesignSurface has implemented the
IComponentChangeService internally, so we can just get this interface and
monitor its ComponentChanged interface. Sample code snippet listed below:

private void Form1_Load(object sender, EventArgs e)
{
DesignSurface surface = new DesignSurface();
surface.BeginLoad(typeof(Form));
Control view = (Control)surface.View;
view.Dock = DockStyle.Fill;
IComponentChangeService component =
(IComponentChangeService)surface.GetService(typeof (IComponentChangeService))
;
component.ComponentChanged += new
ComponentChangedEventHandler(component_ComponentCh anged);
Form myDesigner = new Form();
myDesigner.Controls.Add(view);
myDesigner.Show();
}

void component_ComponentChanged(object sender, ComponentChangedEventArgs e)
{

if (e.Member.DisplayName == "Width" || e.Member.DisplayName == "Height")
{
Console.WriteLine("Size changed with old value" +
e.OldValue.ToString() + " and new value" + e.NewValue.ToString());
}
}
This code works well on my side. It will monitor the Width and Height
property change without any problem. Based on the test, this event will be
fired 2 times:
1. When we start the control size changing
2. When we finished control size changing.

So I think we should filter the first one and use the second event firing
as the sizing end.

I have also attached the project in this rely, for your information.

Hope it helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights

Jun 7 '06 #4
If you need further help, please feel free to post. Thanks!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
6
by: Shimon Sim | last post by:
I have Panel control on the page. I am handling Init event for it. It doesn't seem to fire at all. Why? Thank you Shimon.
5
by: Martin | last post by:
I have created a subclass of a textbox. In this subclass I have a property called 'Caption'. If this property contains a value then I want to create a Label object and add it to the controls...
3
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
In the page_load event i need to see which event fired the post back. what here allows this. I specificly want to know if the enter key was pressed. but i need to check for others. -- (i''ll be...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.