Although this post doesn’t seem like rocket science, I simply couldn’t find a reference for this technique online so I documented it here.
I have an application that a user interacts with primarily as a system tray icon. I want to show the same context menu popup whether the icon is left or right clicked. I knew this could be done because Live Messenger works exactly this way when it is minimized to the system tray. I messed around for almost an hour looking for how to make the context menu show up in the right place on the screen. I even found this crazily complex approach:
http://www.codeproject.com/useritems/notifyicondualmenus.asp
Finally I noticed the the ContextMenuStrip.Show() function was overloaded like this ContextMenuStrip.Show(Point p) so that I can simply do this:
private void _trayNotifyIcon_Click(object sender, EventArgs e) { this._trayContextMenuStrip.Show(Cursor.Position); }
Isn’t that disgustingly simple? Now I know.
I didn’t even think of that. Thanks for the post.