|
-
Sep 27th, 2001, 02:05 PM
#1
Thread Starter
Junior Member
Handling Systray Icon Events
I have a program that creates a systray icon using ShellNotifyIcon and assigns a message value to it that is supposed to be passed back to the owner window when activity takes place. How do I intercept this message in my program? Is there a site you can reccomend that would outline how to intercept a message in a vb program and create an event based on it?
Thanks for any help.
-
Sep 27th, 2001, 02:41 PM
#2
Thread Starter
Junior Member
I know it involves Subclassing..
but I cannot find any good code that demonstrates the process of subclassing. I did find one site that included an already compiled OCX file that would handle subclassing, but I want to understand what is going on behind the scenes there.
-
Sep 27th, 2001, 03:25 PM
#3
Member
So, was the test a success?
-
Sep 27th, 2001, 05:08 PM
#4
Thread Starter
Junior Member
hmmm...
Well, I'm glad this thread is at least good for something, even if it is just testing your ability to post.
-
Sep 27th, 2001, 06:05 PM
#5
Member
Try checking out http://www.mvps.org/vbnet or http://www.vbsquare.com/ for tutorials on subclassing.
-
Sep 27th, 2001, 08:32 PM
#6
Thread Starter
Junior Member
looks like the info there will helpful.. thanks for the sites.
-
Sep 28th, 2001, 01:30 AM
#7
Here is a class that probably does what you want hopefully it helps. If not then don't mind me I am always pimping sample projects.
It shows how to catch the rightclick and doubleclick and what not events on the tray icon.
-
Sep 28th, 2001, 06:57 PM
#8
Thread Starter
Junior Member
hey Edneeis....
your example does work correctly, but i am confused about one part of the code. In the sub below, MSG is assigned a value of X / Screen.TwipsPerPixelX, which as i understand it should be the x coordinate in pixel notation of the mouse when moved over the form/icon. How does a case statment of the x pixel coordinate correctly interpret the messages? If any one knows what I'm missing, please fill me in. Thanks.
Private Sub OwnerForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static rec As Boolean, MSG As Long
MSG = X / Screen.TwipsPerPixelX
If rec = False Then
rec = True
Select Case MSG
Case WM_LBUTTONDBLCLK:
RaiseEvent DblClick
Case WM_LBUTTONDOWN:
RaiseEvent MouseDown(vbLeftButton)
Case WM_LBUTTONUP:
RaiseEvent MouseUp(vbLeftButton)
Case WM_RBUTTONDBLCLK:
RaiseEvent DblClick
Case WM_RBUTTONDOWN:
RaiseEvent MouseDown(vbRightButton)
Case WM_RBUTTONUP:
RaiseEvent MouseUp(vbRightButton)
End Select
rec = False
End If
End Sub
-
Sep 28th, 2001, 08:37 PM
#9
I am not sure exactly why that works. It does seem weird. I just took bits and pieces of different examples and fixed it up into a class and went with it. I guess it has something to do with the X being the X from the MouseMove event????????????
But hey if it works then its all good right.
Although it is nice to understand whats happening.
-
Sep 28th, 2001, 09:27 PM
#10
Thread Starter
Junior Member
yeah, I even looked at the documentation for the mousemove event of a form thinking that maybe VB considers a mouse button press event to also be a mouse move event and then alters the values of X and Y accordingly So i put a statment in the routine, MSG2 = Y/ Screen.TwipsperpixelY to determine the value of Y, and it is always 0.
So, I next added a MouseMove routine to the main form, which, when the program was in Icon form, returned the same values as the one from the object. But when in "Form mode", it returns values that make sense. Seems like there could be a problem if the form happened to be in a place where the mouse retuned the same value as the messages, which, granted, would require a screen size of 2308x1704, but could happen. Apparently the Systray must intercept the MouseOver/Button commands and then replace them with values relavent to the event. And the values it sends back don't change with the screen size, so there could be a problem under these conditions.
Is there anyone who can verify that this is correct? Does anyone know for a fact that the systray modifys the X/Y values when the mouse is in its region? I'm just curious now ...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|