473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Context menu and notifyicon - event not firing?

Hi, I've got a simple program that contains a windows form with 3 command
buttons on. The project also includes a notifyicon and a context menu. The
context menu has 3 menu items (mirroring the 3 command buttons), with each
menu item firing the corresponding command buttons performclick event (eg.
on selecting menuitem1, fires the command1.performclick event).
Problem is that occassionally, selecting the menuitems does nothing. Any
ideas? Would it be better to place the commandbutton code into seperate
procedures and call these from the menu and commandbuttons?

Mark
Nov 20 '05 #1
4 2523
* "riggs" <ri*****@hotmail.com> scripsit:
Hi, I've got a simple program that contains a windows form with 3 command
buttons on. The project also includes a notifyicon and a context menu. The
context menu has 3 menu items (mirroring the 3 command buttons), with each
menu item firing the corresponding command buttons performclick event (eg.
on selecting menuitem1, fires the command1.performclick event).
Problem is that occassionally, selecting the menuitems does nothing. Any
ideas? Would it be better to place the commandbutton code into seperate
procedures and call these from the menu and commandbuttons?


Does this sample work for you?

<http://www.mvps.org/dotnet/dotnet/samples/windowsandforms/downloads/SimpleNotifyIcon.zip>

Does the code work if you do not use 'PerformClick'?

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Dilbert's words of wisdom #18: Never argue with an idiot. They drag you down
to their level then beat you with experience.
Nov 20 '05 #2

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e2****************@TK2MSFTNGP12.phx.gbl...
Does the code work if you do not use 'PerformClick'?


Hi Herfried, I added a bit of code to one of my menu items, so that it would
display a messagebox before performing the 'performclick' :

Private Sub mnuupdate_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles mnuupdate.Click
MessageBox.Show("hello")
cmdupdate.PerformClick()
End Sub

The messagebox was displayed, but the cmdupdate code was not executed.

Mark
Nov 20 '05 #3
* "Mark Harris" <ri*****@hotmail.com> scripsit:
Does the code work if you do not use 'PerformClick'?


Hi Herfried, I added a bit of code to one of my menu items, so that it would
display a messagebox before performing the 'performclick' :

Private Sub mnuupdate_Click(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles mnuupdate.Click
MessageBox.Show("hello")
cmdupdate.PerformClick()
End Sub

The messagebox was displayed, but the cmdupdate code was not executed.


Add the code from 'cmdUpdate_Click' to a separate procedure. Then call
this procedure from the button's 'Click' event handler and
'mnuupdate_Click' instead of using 'PerformClick'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Dilbert's words of wisdom #18: Never argue with an idiot. They drag you down
to their level then beat you with experience.
Nov 20 '05 #4

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uH**************@TK2MSFTNGP09.phx.gbl...

Add the code from 'cmdUpdate_Click' to a separate procedure. Then call
this procedure from the button's 'Click' event handler and
'mnuupdate_Click' instead of using 'PerformClick'.


That does the trick.

Thanks
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Lalit | last post by:
Hi Friends, I have developed a Windows service. Now i need icon for this service in systray and context menu fo this icon. Can i do this? With regards, Lalit
2
by: Eric | last post by:
I implemented owner drawing on the main and context menus of my main form. It works fine. There is also a notify icon control that has a context menu. When the icon is in the status bar, it...
1
by: David | last post by:
Hi, I am developing a NotifyIcon app with C#. I want to show the context menu when user left-clicks on the icon, the same as he/she right-clicks on it. In that event handler,...
4
by: Claire | last post by:
Sorry Ive added this twice (sortof) but if I'd added an addendum to the first one then this would probably have been ignored. This problem affects a ContextMenu attached to a NotifyIcon object. I...
2
by: Heather R | last post by:
I am writing a windows service that has a notifyicon component. The component displays accordingly, but for some reason, I cannot get the click or double click event to fire. It seems like none of...
0
by: Neo | last post by:
I have created a Windows Service that shows a notifyicon in the system tray. I have also created a context menu for the notifyicon and implemented the notifyicons click event. The notifyicon...
4
by: ewokspy | last post by:
I have a system tray icon with a context menu set to appear on right-click. On a right click the menu appears fine and I can select an option. The problem is that the event doesn't fire immediately....
2
by: stillcoding | last post by:
Hi I have a problem with memory usage increasing when I right click to display the context menu on a notifyIcon OS: Windows XP Professional SP2 Software: VS2005 Professional edition SP1 The...
1
by: \Ji Zhou [MSFT]\ | last post by:
Hello Jason, Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou and I will be working on this issue with you. I have tried to but cannot reproduce your issue on my side....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.