By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,634 Members | 1,897 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,634 IT Pros & Developers. It's quick & easy.

How to pass Composite Control messages to the parent Form?

P: n/a
Hello,

I developed a Composite Control with Visual C# (Rocker Button). The button
detects MouseUp events inside the control. However I would like these
MouseUp events to be transferred to the parent form of this control so I can
update the form with the new information.

The messages are trapped inside the control but are not seen by the parent
form.

Any idea how to do that?

EitnaB
Nov 20 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 2007-11-20 14:55:02 -0800, Eitan <Ei***@discussions.microsoft.comsaid:
Hello,

I developed a Composite Control with Visual C# (Rocker Button). The button
detects MouseUp events inside the control. However I would like these
MouseUp events to be transferred to the parent form of this control so I can
update the form with the new information.

The messages are trapped inside the control but are not seen by the parent
form.

Any idea how to do that?
While it would be possible to do that, it seems to me that you would
rather use an event to signal the change in the state of the control,
or to react to a specific state.

For example, there's the Control.Click event, which something like a
Button control will use to signal that the button has actually been
successfully depressed and released.

Or you could go the data-centric route. For example, the
Control.TextChanged event will signal when the Text property has
changed.

For a "rocker button", I would think you would expose a single state as
a property (perhaps using an enumeration). If the property is named
RockerState, then you might have a RockerStateChanged event that the
parent form or any other code could subscribe to, for the purpose of
learning when the state of the rocker switch has changed.

Alternatively, you could have events corresponding to each position the
rocker button could have, with each event being raised as the rocker
changes position. I would prefer the previous idea, but this would
work too.

For me, the mouse events are more for use by the control itself to
handle interactions with the user. Higher-level control and signaling
should be implemented with a higher-level paradigm.

Pete

Nov 20 '07 #2

P: n/a
Hi,

did you try KeyPreview in the Parent Form?
Otherwise you can use SendMessage API
to transfer the messages to the upper level
parent control. You can subclass the parent
control or the child control and route the messages
in booth directions using SendMessage API
from Windows API,...

Hope this helps,...
Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
ke*****@arcor.de

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
-----------------------
"This reply is provided as is, without warranty express or implied."
Nov 20 '07 #3

P: n/a
Hello Pete,

My problem is how to expose RockerStateChanged event (for example) like you
suggested. I did expose properties with no problem but having difficulty to
send events to the hosting form.

Thanks
EitanB

"Peter Duniho" wrote:
On 2007-11-20 14:55:02 -0800, Eitan <Ei***@discussions.microsoft.comsaid:
Hello,

I developed a Composite Control with Visual C# (Rocker Button). The button
detects MouseUp events inside the control. However I would like these
MouseUp events to be transferred to the parent form of this control so I can
update the form with the new information.

The messages are trapped inside the control but are not seen by the parent
form.

Any idea how to do that?

While it would be possible to do that, it seems to me that you would
rather use an event to signal the change in the state of the control,
or to react to a specific state.

For example, there's the Control.Click event, which something like a
Button control will use to signal that the button has actually been
successfully depressed and released.

Or you could go the data-centric route. For example, the
Control.TextChanged event will signal when the Text property has
changed.

For a "rocker button", I would think you would expose a single state as
a property (perhaps using an enumeration). If the property is named
RockerState, then you might have a RockerStateChanged event that the
parent form or any other code could subscribe to, for the purpose of
learning when the state of the rocker switch has changed.

Alternatively, you could have events corresponding to each position the
rocker button could have, with each event being raised as the rocker
changes position. I would prefer the previous idea, but this would
work too.

For me, the mouse events are more for use by the control itself to
handle interactions with the user. Higher-level control and signaling
should be implemented with a higher-level paradigm.

Pete

Nov 21 '07 #4

P: n/a
On 2007-11-21 06:58:02 -0800, Eitan <Ei***@discussions.microsoft.comsaid:
My problem is how to expose RockerStateChanged event (for example) like you
suggested. I did expose properties with no problem but having difficulty to
send events to the hosting form.
Well, what did you try? What didn't work?

Pete

Nov 21 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.