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

How to cancel this event

Hi there,

Does anyone know how to actually "abort" the event (component change)
described in the following link. Apparently it's doable as mentined in the
"Remarks" section but how. Alternatively, it would be better to prevent this
event from being raised in the first place if anyone knows the procedure.
Note that my users will be modifying a form's properties on a
"System.ComponentModel.Design.DesignSurface" and I simply want to disable
their ability to drag and resize a ontrol using the mouse, keyboard, etc.
Thanks.

http://msdn2.microsoft.com/en-us/lib...ng(VS.80).aspx
Jan 23 '07 #1
6 8647
igd
Just override the event handler in your class and do not call base(...)
in the overidden event handler:

protected override void OnComponentChanged(
Object component,
MemberDescriptor member,
Object oldValue,
Object newValue
)
{
// now this handler is called instead of the handler of the base
class when
// the ComponentChanged-event occurs
}

Rob Peterson schrieb:
Hi there,

Does anyone know how to actually "abort" the event (component change)
described in the following link. Apparently it's doable as mentined in the
"Remarks" section but how. Alternatively, it would be better to prevent this
event from being raised in the first place if anyone knows the procedure.
Note that my users will be modifying a form's properties on a
"System.ComponentModel.Design.DesignSurface" and I simply want to disable
their ability to drag and resize a ontrol using the mouse, keyboard, etc.
Thanks.

http://msdn2.microsoft.com/en-us/lib...ng(VS.80).aspx
Jan 23 '07 #2
Just override the event handler in your class and do not call base(...)
in the overidden event handler:

protected override void OnComponentChanged(
Object component,
MemberDescriptor member,
Object oldValue,
Object newValue
)
{
// now this handler is called instead of the handler of the base
class when
// the ComponentChanged-event occurs
}
Thanks for the response. I wish it were that easy however (or maybe it is
but I'm still mucking around with this stuff). What I've done is download a
component posted by a MSFT blogger which I'm now trying to unravel out so I
can customize it (see here if you're interested
http://blogs.msdn.com/mharsh/archive...4/395304.aspx). His component
allows you to display an arbitrary form in design mode (at runtime) so users
can change it just like programmers do in the VS forms designer (it's really
a mini component that wraps the latter). What basically happens is that you
pass his component an arbitrary form and it does the following:

1) Creates a new (blank) "Form" which encapsulates a "DesignSurface" member
(initializing it accordingly)
2) Copies the form you passed onto the newly created "DesignSurface" (in 1
above)
3) Invokes "DesignSurface.GetService()" to retrieve an
"IComponentChangeService" interface
4) Sets the "ComponentChanging" event on the above interface to capture any
user changes

You can now call "ShowDialog()" on the form created in 1) above and it
displays the form you passed on a design surface just like in the VS form's
designer. You can therefore move and resize all your form's controls just
like in VS. I want to prevent this however. Item 4) above is invoked
whenever the user makes any changes so I can't simply provide an override
(or don't see how at this point but I'm not sure if it's the correct
approach here even if it is doable). Doing nothing in the handler has no
effect BTW as the user's changes are still processed. I'd really just like
to prevent the user from moving/resizing the controls in the first place but
still can't find a way to do it. I think I might have to make the control's
size and locations properties read-only but I've played with this and can't
figure out how to do it. Any additional insight would be welcome though I
realize it may be a lot to swallow if you're not already familir with this
stuff. Thanks.
Jan 23 '07 #3
This event is supressed during loading/unloadin the control since obviously
the whole internal state of the event is changed, thus it doesn't give much
information.

In order to cancel a property from changing you need to throw an exception
form the IComponentChangeService.ComponentChangingevent handler
--
HTH
Stoitcho Goutsev (100)

"Rob Peterson" <no_spam@_nospam.comwrote in message
news:Op**************@TK2MSFTNGP03.phx.gbl...
Hi there,

Does anyone know how to actually "abort" the event (component change)
described in the following link. Apparently it's doable as mentined in the
"Remarks" section but how. Alternatively, it would be better to prevent
this event from being raised in the first place if anyone knows the
procedure. Note that my users will be modifying a form's properties on a
"System.ComponentModel.Design.DesignSurface" and I simply want to disable
their ability to drag and resize a ontrol using the mouse, keyboard, etc.
Thanks.

http://msdn2.microsoft.com/en-us/lib...ng(VS.80).aspx


Jan 23 '07 #4
This event is supressed during loading/unloadin the control since
obviously the whole internal state of the event is changed, thus it
doesn't give much information.

In order to cancel a property from changing you need to throw an exception
form the IComponentChangeService.ComponentChangingevent handler
Thanks very much! That actually works but the documentation makes no mention
of it which worries me (is it officially supported). While I will rely on it
if necesarry (I need to find out if it is supported first), it's still a
little unwieldy. That is, the user is still able to move the control but
throwing the exception causes the system to "pop" it back into place (not
the cleanest approach by MSFT). I'd really like to know how to prevent users
from moving it in the first place noting that the sizing grips still appear
around the control when the user clicks it. This misleads them into thinking
they can re-size it (the exception actually prevents it) so there must be a
way of disabling all this without spending a month investigating things. At
least I now have a fallback method just in case however. Thanks again for
your help (greatly appreciated).
Jan 23 '07 #5
Actually throwing exception is documented in MSDN as the way of preventing
component from changing.
http://msdn2.microsoft.com/en-us/lib...tchanging.aspx

As far as it goes for freazing the control so it cannot be moved or hiding
the resizing handlers I believe this is possible to be achieved by the
Behavior Service. I haven't done it myself, but as a starting point I'll
suggest read through the following MSDN article:
http://msdn2.microsoft.com/en-us/library/ms171820.aspx

Here also links to information regarding classes participating in the
designtime behavior feature:
BehaviorService class
http://msdn2.microsoft.com/en-us/lib...orservice.aspx
Behavior class
http://msdn2.microsoft.com/en-us/lib....behavior.aspx
Glyph class
http://msdn2.microsoft.com/en-us/lib...ior.glyph.aspx
Adorner class
http://msdn2.microsoft.com/en-us/lib...r.adorner.aspx
--
HTH
Stoitcho Goutsev (100)


"Rob Peterson" <no_spam@_nospam.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>This event is supressed during loading/unloadin the control since
obviously the whole internal state of the event is changed, thus it
doesn't give much information.

In order to cancel a property from changing you need to throw an
exception form the IComponentChangeService.ComponentChangingevent handler

Thanks very much! That actually works but the documentation makes no
mention of it which worries me (is it officially supported). While I will
rely on it if necesarry (I need to find out if it is supported first),
it's still a little unwieldy. That is, the user is still able to move the
control but throwing the exception causes the system to "pop" it back into
place (not the cleanest approach by MSFT). I'd really like to know how to
prevent users from moving it in the first place noting that the sizing
grips still appear around the control when the user clicks it. This
misleads them into thinking they can re-size it (the exception actually
prevents it) so there must be a way of disabling all this without spending
a month investigating things. At least I now have a fallback method just
in case however. Thanks again for your help (greatly appreciated).

Jan 24 '07 #6
Actually throwing exception is documented in MSDN as the way of preventing
component from changing.
http://msdn2.microsoft.com/en-us/lib...tchanging.aspx
Thanks very much. The link I was looking at was for the event since that's
what I'm hooking. Unlike the method in the above link, it makes no mention
of the exception. See here:

http://msdn2.microsoft.com/en-us/lib...ng(VS.80).aspx
As far as it goes for freazing the control so it cannot be moved or hiding
the resizing handlers I believe this is possible to be achieved by the
Behavior Service. I haven't done it myself, but as a starting point I'll
suggest read through the following MSDN article:
http://msdn2.microsoft.com/en-us/library/ms171820.aspx

Here also links to information regarding classes participating in the
designtime behavior feature:
BehaviorService class
http://msdn2.microsoft.com/en-us/lib...orservice.aspx
Behavior class
http://msdn2.microsoft.com/en-us/lib....behavior.aspx
Glyph class
http://msdn2.microsoft.com/en-us/lib...ior.glyph.aspx
Adorner class
http://msdn2.microsoft.com/en-us/lib...r.adorner.aspx
I'll take a look at this. I'm very new to this area but I know that .NET 2.0
introduced the "DesignSurface" class which is what I'm working with (not a
custom designer per se). I'm still working on a conceptual understanding of
the issues however so it will take some time to get my head wrapped things.
Thanks again though.
Jan 24 '07 #7

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

Similar topics

10
by: Hautzendorfer | last post by:
Hello, I'm currently working on some printing stuff: I have to print out several .xml files using a stylesheet. Therefor I choose the Internetexplorer PlugIn via SHDocVW. My problem: After...
11
by: ryanmhuc | last post by:
I have a function which needs to cancel the input into a text field on a form. I cancel the event in IE fine and the text does not get entered. But for firefox (1.0) I cancel the event and the text...
1
by: AP | last post by:
Hi, I'm trying to use c# to pop up a dialog box when a user attempts to close word to prompt them if they want to exit or cancel (obviously other stuff needs to happen based on their selection...
1
by: VM | last post by:
How can I cancel all running processes in my application when I click on the Cancel button? When the Run button's clicked, it creates an instance of a specified class and runs a method that reads...
2
by: Boni | last post by:
Dear all, I would like to cancel the keydown event after I handled it in my control. But the handled=true of the event don't do the job. Is the some stronger method to clear key buffer and remove...
1
by: sck10 | last post by:
Hello, When using a FormView, DetailsView or GridView, how do you capture the cancel event when you are in the insert/update mode. I have a formview that I need to hide if the person clicks on...
1
by: dave | last post by:
What I am attempting to do is cancel an event in IE inside of my event handler, but the handler keeps getting called: for example if I do <div id="foo"> <div id="test">test text</div> </div>...
5
by: Diego | last post by:
How do I capture a cancel event of Printer dialog box? Regards, Diego
2
by: =?Utf-8?B?TmVldGE=?= | last post by:
Hi, I creating a console application. In that I want to catch the cancel event of the console application .Please guide me in this.I figured out that I will have to attach event to the...
7
by: John Gault | last post by:
I experimented with a snippet of JavaScript that will display a "Please Wait" message and graphic while the results of a cgi script is running (the script grabs a bunch of data and formats it in a...
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
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
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
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...

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.