I have a winform application (.NET C#). From this application I have started another process (notepad.exe) and docked it to my window - similar to how it was done here: Docking Window inside another Window.
Now my question is, how can I catch/handle mouse events made on this docked application? What I've tried:
- creating a transparent panel over the docking panel. The issue arose when I couldn't click (or do anything else) "through" the invisible panel
- global mouse hook. I didn't like this solution because I'm only interested in the mouse position within my form. Plus, I need the mouse position relative to the window.
For context, what I'm trying to achieve is to have a constant tooltip next to my mouse informing me of the mouse position relative to the panel. See the code bellow:
ToolTip trackTip;
public Form1
{
trackTip = new ToolTip();
transparentPanel1.MouseMove += new MouseEventHandler((object s, System.Windows.Forms.MouseEventArgs e) => trackTip.Hide(this));
transparentPanel1.MouseLeave += new EventHandler(TransparentPanel1_MouseLeave);
}
void TransparentPanel1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
String tipText = String.Format("({0}, {1})", e.X, e.Y);
trackTip.Show(tipText, this, e.Location);
}
I've found a viable solution, however I would very much like to avoid injecting code into the process and I feel as though there must be a better solution to my specific problem.
I'd appreciate any pointers you could give me. I'm new to .NET programming.