How to pass Composite Control messages to the parent Form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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ü
(e-mail address removed)

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/
 
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
 
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
 
First I was trying to detect the MouseUp from the Control. The control has a
button inside and the button is handling the MouseUp (and so on...), so my
Form does not get a MouseUp event from the Control.

As to RocketStateChanged type of event, I did not do anything. I can not
find in the documentation were there is a discussion on how to fire such an
event. Do you know where I can find such info?

Thanks
EitanB
 
First I was trying to detect the MouseUp from the Control. The control has a
button inside and the button is handling the MouseUp (and so on...), so my
Form does not get a MouseUp event from the Control.

If I understand correctly: you have a form, which contains your
composite control, which itself contains buttons corresponding to the
state of the rocker switch?

Your composite control would then want to subscribe to the Click events
of the contained buttons, detecting user interaction that way. Again,
the mouse events are for the control that actually needs to directly
process the user input; for the higher-level behavior, you want to use
higher-level events.
As to RocketStateChanged type of event, I did not do anything. I can not
find in the documentation were there is a discussion on how to fire such an
event. Do you know where I can find such info?

Did you look in the MSDN documentation for the C# language under the
"event" keyword?

Pete
 
Pete,

Well, your comment of: "Did you look in the MSDN documentation for the C#
language under the event" keyword?" was the missing link....

Solved it. Never created Events before....

Thanks
EitanB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top