开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜