Peter,
Thanks again to the pointer. I read more on events and delegates and come
with this code:
namespace test
{
public class mouseEvent : EventArgs
{
public string message = null;
public EventArgs e = null;
}
public class eventHandling
{
public event EventHandler Changed;
public void onChanged(mouseEvent e)
{
if (Changed != null)
Changed(this, e);
}
}
}
namespace test
{
public partial class Form1 : Form
{
private eventHandling eventhandle = new eventHandling();
public Form1()
{
InitializeComponent();
eventhandle.Changed += new EventHandler(MouseMoveHandler);
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
string message = "x: " + e.X.ToString() + " y: " + e.Y.ToString();
mouseEvent parm = new mouseEvent();
parm.e = e;
parm.message = message;
eventhandle.onChanged(parm);
}
private void MouseMoveHandler(object sender, EventArgs e)
{
mouseEvent parm = (mouseEvent)e;
label1.Text = parm.message;
}
}
}
The second section of the code is on the child form. When doing the test, I
can see my text updated with the current position of the cursor. But it does
not update the text on other child forms. The text is updated only for its
own window. How can I make all the child form see the same message?
Thanks in advance,
Anthony.
"Peter Duniho" wrote:
ATT wrote:
Thanks for the suggestion. I have an override on OnMouseMove on the child
form. This is how I capture there is some movement on my application. You
mention "raise the static event so that all of the other instances of the
same class know about it." The question is how? I am new in Window
programming. Can you provide more detail on how to raise the event?
You may find this helpful:
http://msdn2.microsoft.com/en-us/lib...39(VS.71).aspx