notifyIcon.BalloonTipClicked firing when tray icon is clicked - c#

I have a tray app backed by a NotifyIcon. It sometimes fires toast notifications via notifyIcon.ShowBallonTip(). It is running on Windows 10 1607.
I'm subscribed to the following two events:
notifyIcon.MouseUp += notifyIcon_MouseUp;
notifyIcon.BalloonTipClicked += notifyIcon_BalloonTipClicked;
At first glance everything works great:
When I click on the tray icon, I get the MouseUp event and the correct things happen
When I click on the toast, I get the BalloonTipClicked event and the correct things happen
The bug in the app right now is that if the user clicks on the tray icon while the toast is showing, it acts as if the user clicked on the toast instead. In other words, clicking on the tray icon while the balloon/toast is showing will fire BallonTipClicked even though the balloon/toast was never actually clicked.
When I am in BalloonTipClicked the "sender" is just the NotifyIcon. I don't see any way of distinguishing "balloon tip clicked" vs "tray icon clicked". I mean, the event itself is called BallonTipClicked so I have no idea why it fires when I click the app icon.
According to MSDN this should not be happening:
BalloonTipClicked: Occurs when the balloon tip is clicked.
MouseUp: Occurs when the user releases the mouse button while the pointer is over the icon in the notification area of the taskbar.
Are the docs wrong? Any ideas for getting the behavior I intend?

Related

How to click button when out of focus

I have two Windows forms on a Program.
E.g) MainForm, SubForm
SubForm have a focus and I tried click a button on the MainForm but I had to click twice because of out of focus.
I think MainForm get focus when first click and make click event when second click so I want to making click event pass the "Getting Focus" process.
How can I do?
Sorry for bad english describing.
Thank you.
=== add photo for describing ===
GIF Image

Handle button which has drill-down menu

So i have a UI that when you right click on a button, it opens a screen with 3 other buttons on it. How do i get the event system to not override the last button clicked (being what i right clicked to open the screen) when i click down on the button that is opened. The only way i can think to do it is to store the button that was right clicked in another variable. I was wondering if there was a way to prevent the event system from overriding the last button pressed. So that my code will run off what was right clicked and not the button that was clicked.

.NET CF Don't trigger button-click on return

I have a c# .net cf 3.5 application on windows mobile 6.5
On a form there are several buttons with onclick-events.
How do I prevent the events from triggering, if they were sent by a return (on the software or hardware-keyboard) an not a "real" click?
Can I find out, which action sent the click-event?
There are three ways to prevent the Enter button to trigger Click.
Make a dummy/hidden button as the AcceptButton of the form. That way
any Enter press would trigger that button instead.
Change the event handler to trigger on MouseUp or MouseDown instead
Subscribe to GotFocus event and set it to Focus on other control
instead. That way it won't receive Enter event

NO ACTIVATE window style

I need a window that does not activate when I click on it but is should elsewhere react normal. By normal I mean if there is a button on it and I click on the button it should execute the click and call the click function ( or event handle or what so ever). So it should be a normal window except that it shouldn't get activated when you interact with it.
I know you can do this with a message filter or hooks but is there any window style that does this automatically?
this is for windows.
thanks!
Have you tried the WS_EX_NOACTIVATE extended window style?
A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.
To activate the window, use the SetActiveWindow or SetForegroundWindow function.
Otherwise, if that doesn't do what you want, you will need to handle the WM_MOUSEACTIVATE message and return MA_NOACTIVATE.

Use right-click with Windows Forms Button

I am writing an app where the user should be able to alter the action of a button.
The user should right-click a button, and choose an option from a pop-up context menu. Once the choice has been made the button will perform a different action when the user uses a normal click.
I've already gotten the "Click" event working for a normal button click, however the "MouseClick" event handler isn't working correctly.
The "MouseClick" event gets activated on regular left-clicks, but never get's called for right-click.
Is there some default event handling being performed that is ignoring that right-click?
I'm sorry to say that this would be a serious UI blooper. Perhaps it would make more sense to add a small combobox next to the button.
Perhaps something like this?
http://www.codeproject.com/KB/buttons/SplitButton.aspx
If you want to display a context menu with actions to choose from it should be enough to assign a ContextMenuStrip to the ContextMenuStrip property. There is usually no need to manually handle the mouse events for that.
surely it would be better to implement it on the MouseDown event rather than the MouseUp event. i dont understand how this is much different from MouseClick event
edit: Just tried this and it works a treat :)
In Button (and certain other controls), the MouseClick event is only fired for the left button. Refer to MSDN.
If you want to know about the right button, respond to the MouseUp event--though as other posters have pointed out, this isn't a great UI idiom.
Use the Mouse UP event... test that Button.X and Button.Y are within the size of the button otherwise you have moved the mouse away from the button.
Terry G

Categories

Resources