You can listen to the control''s mouse messages through their MouseUp, MouseDown, etc. events as you probably know already. But, those events are fired after they get processed by the control itself.
To "preview" these events, you could set up a filter in your Form by implementing the IMessageFilter interface. See .net class ref for that interface.
RMRyan Milligan April 8, 2004 11:22 AM
Yes, this is what I am looking for. I have a form with an axwebbrowser control which does not have a click event. I need to be able to recognize when the xbuttons have been clicked so I can call the back() and forward() methods of the browser.
Could anyone please provide an example of how this can be accomplished.
ARAnthon Ryan MilliganApril 14, 2004 08:53 AM
I figured it out using the information you provided. It works great. Below is my code:
Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim filter As New MyFilter()
filter.frm = Me
Public Class MyFilter
Implements IMessageFilter 'gets the left mouse button messages
Public frm As frmMain
Public Const WM_XMOUSEDOWN As Integer = 523
Public Const WM_XMOUSEUP As Integer = 524
Public Const WM_XMOUSEDBL As Integer = 525
Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
If m.Msg = WM_XMOUSEDOWN Or m.Msg = WM_XMOUSEUP Then
frm.frmMain_MouseUp(frm.ActiveBrowser, New System.Windows.Forms.MouseEventArgs(frm.MouseButtons, 1, frm.MousePosition.X, frm.MousePosition.Y, 0))