I have a form that prefilters some messages by implementing the IMessageFilter interface and implementing this method:
System.Windows.Forms.IMessageFilter.PreFilterMessage
This thing is beginning to annoy me, but it has generally been working. I may try to find another solution to whatever it is there for, but at the moment I am working on something else. In fact, I am working on a whole different form. The form that implements the messagefilter is created, but not shown, at the time this latest problem arises. Therefore, the form instance exists, so the prefilter is in existence, but the form is not visible or accessible.
Inside the method, I have these lines:
the first If statement can probably be removed, but it's a good check to have in place. the display surface is not disposed, as the form hasn't even been shown, yet. I then get a point for the mouse position, and check to see whether the panel (on a form that has not yet been shown) contains the point. The problem is: This is returning True!!!
The form hasn't been shown, but since it was created, all of the objects have also been created. So, the mouse may actually be on the thing. Therefore, I need a way to determine whether the click was even on the form, which it was not. A couple alternatives would be to position the form off the screen until it is needed, then move it back to the screen in the Shown event. There are problems with that, but not insurmountable problems. Another alternative would be to check whether the form is accessible, but that's not a great solution, because this form is shown non-modally, so other forms can be on top of it. In that scenario, it could be visible, and active, but still wouldn't be the form that the mouse was clicked on.
Is there another way to determine whether a click was on a specific form? I need some way to determine whether a form is even the one that the user was interacting with before pre-filtering the message. Since the pre-filter is just what it says, I believe that the mouse events on the form itself are all too late.
EDIT:
This is all related to this thread (which reminds me a lot of what this whole thing was about):
http://www.vbforums.com/showthread.p...g-Mouse-Events
In the final post (which is quite possibly the only one worth reading), I talk about adding and removing the message filter. I was doing that early on. I'm going to try doing that only when needed, but I will have to figure out what the problem with removing the message filter was all about.
System.Windows.Forms.IMessageFilter.PreFilterMessage
This thing is beginning to annoy me, but it has generally been working. I may try to find another solution to whatever it is there for, but at the moment I am working on something else. In fact, I am working on a whole different form. The form that implements the messagefilter is created, but not shown, at the time this latest problem arises. Therefore, the form instance exists, so the prefilter is in existence, but the form is not visible or accessible.
Inside the method, I have these lines:
Code:
If Not Me.pDisplaySurface.IsDisposed Then
Dim pt As Drawing.Point = Me.pDisplaySurface.PointToClient(MousePosition)
If Me.pDisplaySurface.ClientRectangle.Contains(pt) Then
The form hasn't been shown, but since it was created, all of the objects have also been created. So, the mouse may actually be on the thing. Therefore, I need a way to determine whether the click was even on the form, which it was not. A couple alternatives would be to position the form off the screen until it is needed, then move it back to the screen in the Shown event. There are problems with that, but not insurmountable problems. Another alternative would be to check whether the form is accessible, but that's not a great solution, because this form is shown non-modally, so other forms can be on top of it. In that scenario, it could be visible, and active, but still wouldn't be the form that the mouse was clicked on.
Is there another way to determine whether a click was on a specific form? I need some way to determine whether a form is even the one that the user was interacting with before pre-filtering the message. Since the pre-filter is just what it says, I believe that the mouse events on the form itself are all too late.
EDIT:
This is all related to this thread (which reminds me a lot of what this whole thing was about):
http://www.vbforums.com/showthread.p...g-Mouse-Events
In the final post (which is quite possibly the only one worth reading), I talk about adding and removing the message filter. I was doing that early on. I'm going to try doing that only when needed, but I will have to figure out what the problem with removing the message filter was all about.