Hi all,
I am working on Windows Forms to create a System Tray app. I want it to respond with left clicks too. (By default, system tray icons respond to right clicks).
I got a relevant code too:
using System;
using System.Windows.Forms;
using System.Reflection;
namespace WindowsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void notifyIcon1_MouseUp(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance |
BindingFlags.NonPublic);
mi.Invoke(notifyIcon1, null);
}
}
}
}
This code works well with C#, that is what I tested and the behavior of NotifyIcon was same for both right click and left click on it (the NotifyIcon image).
I have a similar app created with VC++ and want it to respond on Left Click too. The issue which I am facing is "My code opens the contextmenu on left click but when I open context menu that way, it shows in taskbar and doesn't close when I click some where else."
Can anyone suggest some pointers on using/porting the same code to VC++...
Thanks