Print Page | Close Window

TrayIcon MouseDown bug!

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Suite Pro
Forum Description: Topics Related to Codejock Suite Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=9847
Printed Date: 24 April 2024 at 12:14am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: TrayIcon MouseDown bug!
Posted By: nighthawk
Subject: TrayIcon MouseDown bug!
Date Posted: 10 March 2008 at 7:41pm
I am trying to use the MouseDown event on the tray icon to determine when to hide/restore the main window (left button click) vs. when to display a popup menu (right button click).  What I discovered was that in the MouseDown event, every button click shows up as a right button click.

For example, add the following to the suite controls sample application:

Private Sub TrayIcon_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    MsgBox Button
End Sub

The number "2" will pop up for both a right and left mouse click.  A left mouse click should show up as "1". 

The MouseUp event does seem to work correctly but I'm not sure I want to use that event.  A Click event doesn't distinguish between buttons so that won't work for me.



Replies:
Posted By: Oleg
Date Posted: 11 March 2008 at 6:59am
Thanks, Fixed.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jpbro
Date Posted: 11 March 2008 at 10:23am
Hi Oleg,

    Any idea if this:

https://forum.codejock.com/forum_posts.asp?TID=9358

    Will be fixed? (Event sequence for Click, MouseDown, MouseUp out of order)?

Thanks.



Posted By: Oleg
Date Posted: 12 March 2008 at 2:16am
No. These messages comes from OS system tray and we can't change them.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jpbro
Date Posted: 12 March 2008 at 9:28am
So this is a bug in the OS? Because all other controls fire MouseDown, MouseUp, Click...but the TrayIcon fires Click, MouseDown, MouseUp. This means that click is firing before the mouse events (i.e. before the TrayIcon has been clicked!). 


Posted By: Oleg
Date Posted: 13 March 2008 at 10:50am
its not bug. There is no official document that describes order of these events. Why you can't just  use MouseUp instead Click ???

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jpbro
Date Posted: 13 March 2008 at 11:10am
It might not officially be a bug, but it is definitely different behaviour from the behaviour of every other ActiveX control I have used. Click always gets fired after the user releases the mouse button, not before MouseDown.

The MSDN documentation for the click event also mentions this:

Visual Basic Reference

Click Event

Occurs when the user presses and then releases a mouse button over an object. It can also occur when the value of a control is changed.


It's not that big a deal, it just wastes time trying to figure out what is wrong when you expect a certain behaviour based on the way just about every other control behaves.



There is also a better reason why this is a problem. On most controls (for example, the PictureBox control) if the user presses the mouse button down while the mouse pointer is over the control and then changes his mind and moves the mouse off of the control and releases the mouse button, only the MouseDown and MouseUp events fire. Therefore, you can place code in the Click event and it will only execute if the user presses and then releases the mouse button while over the control.

With the TrayIcon, you can't put code in the Click event (because it fires before MouseDown) and if you put it in MouseUp you will have to perform additionaly checks to make sure that the mouse button was released while the mouse pointer was actually over the TrayIcon control.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net