Hey, how would I check if the ContextMenu of a NotifyIcon is popped up or hidden? I tried to AddHandler for the Popup command, but I don't think that did much...
Thanks,
Jon
Printable View
Hey, how would I check if the ContextMenu of a NotifyIcon is popped up or hidden? I tried to AddHandler for the Popup command, but I don't think that did much...
Thanks,
Jon
Don't think you can, unless you can get the handle (HWND) of the menu. If the handle exists then this probably indicates that the menu is visible. ContextMenu is (i think) derived from Form and should have a Hwnd value somewhere.
If not then you might have to resort to some API hackery. This would be a good candidate for a Codebank tutorial if you get it figured out. Let us know how you get on :)
You think there's any way to do it with ContextMenu.Popup() ?
The reason I am asking is I am constantly reassigning context menu to a notifyicon inside a timer (because of the constant changes in the menu), so if the user is holding the contextmenu open (popped up), it will disappear because of the updating... and that's really really annoying... :(
Nevermind, solved that problem...
Thanks,
Jon
Care to tell us how? :)
Sure. The solution does not really solve exactly what I asked for, but it rather oversteps that problem...
My program downloaded a file from a drive, lets say F. It copied it over to its own drive, lets say G. I had a timer that read in all the values from that file and stored them inside a contextmenu as menuitems. The reason I was asking how to know if the user poped up the context menu of a notifyicon, is that the timer was executed every 5 seconds or so and every time it would completely erase the menu and then override it again. That would cause the contextmenu to disappear if the user had it open (which was really annoying, since there was practicly no time left for the user to select from the menu). That's where I got stuck for a little while. Then I realized that it is not necessary to copy over the file and store the contents in a menu IF the contents of the two files are still the same... That would just be a waste of time and CPU usage. So now before the timer executes its original commands, it first checks to see if the two files (on drives F and G) are different. If they are, then it proceeds with substitution of the menu, but if they are the same, then it just exits which makes much more sense... The original file on drive F will not be modified too often, so there is very little chance that the user will be interrupted with the program downloading the new menu.
Like I said, I didn't really solve the problem of finding out if the contextmenu is open or not, but I rather ignored it and found an ulternative way...
P.S.: Who is us by the way? :)
-Jon
This is a forum!! There are lots of people who read the posts, so if you find a solution to a problem, it is good to post it as then other people can get the benefit of it.
I did post it. It's just not often to hear one person speak on the behalf of the whole VBForums community when replying to a post, not to be offensive or anything...