简体   繁体   中英

How can I initiate mouse events in MDI?

I have MDI application where childforms contains picturebox. I want to get pixel value in picturebox.image of activated (fImage activeChild = this.ActiveMdiChild as fImage;) childform.So I need to initiate mouse events first in childform and then write functions in child as well as in parent form to access these events.

// in Child form I initiated event this.pictureBox1.MouseMove +=new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);

// I don't have idea what should my function in childform looklike ( type,get, set)to return me mouse event that is happening in pparentform. Also the function a (type, get , set) in parent form to have access of these events happening in childform. Any suggestion plaese???

public float pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
    x = e.X;
    y = e.Y;

    // not clear how to code it           
}

You should provide a public method in your child form which does what you want and the parent can call this. It is better, simpler, cleaner. Superior in any way to manipulating mouse events. If you insist on that, though, you can call mouse_event with interop. Or calling your own private mousedown handler with reflection, but that's even worse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM