left click and right click – spot the difference??

Had fun this morning figuring out how to get the context menu for MSG Alert to display the same context menu when you right or left click on it. You’d think that ought to be very easy to do (and it is when you know how) but it was totally non obvious to me – the NotifyIcon class only has click, doubleclick, mouseclick etc methods, there aren’t any methods which deal solely with left or right clicks.

I tried a variety of approaches (from the number of messages in forums etc this isn’t a new problem!!), most of which used the NotifyIcon.ContextMenu.Show() method. However when I tried this, although the menu appeared fine, a blank item appeared in the taskbar, which looked really horrible!!! In the ended I opted for the method described here. This seemed to be the only reliable way of doing it.

Whilst doing this I also ‘upgraded’ my menu from ContextMenu to a ContextMenuStrip to take advantage of being able to add icons etc etc.

Leave a Reply

*