Intercepting the WM_HELP message

  • Thread starter Thread starter Michael Lahrkamp
  • Start date Start date
M

Michael Lahrkamp

Hi All:

I'm using VB.NET and want to capture the WM_HELP message in order to trigger
the help file for a PPC application. Anybody got any suggestions? All help
appreciated! This is becoming a critical item.

Thanks,
Mike
 
Thanks for the reply. I've tried downloading the sample, but it appears that
the WinMsg.cs is not included and nowhere to be found on the OpenNetCF site.
This makes this example less useful!

Any other sources out there?

Mike
 
If you downloaded and installed the Smart Device Framework you basically
have everything you need.

The sample should look something like this (I haven't actually tested the
code):
-------------------------------------------
Imports OpenNETCF
Imports OpenNETCF.Drawing
Imports OpenNETCF.Windows.Forms

Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Private Sub InitializeComponent()
Me.MainMenu1 = New System.Windows.Forms.MainMenu()
Me.Menu = Me.MainMenu1
Me.Text = "Form1"

End Sub

#End Region

End Class

Public Class MessageFilter
Implements IMessageFilter

Public Function PreFilterMessage(ByRef m As
Microsoft.WindowsCE.Forms.Message) As Boolean Implements
OpenNETCF.Windows.Forms.IMessageFilter.PreFilterMessage
If m.Msg = WinMsg.WM_HELP Then
OpenNETCF.Diagnostics.Process.Start("peghelp.exe", "test.htm")
End If

End Function
End Class
----------------------------

You have to make sure to add a reference to Microsoft.WindowsCE.Forms
because that is where the Message class is defined.

We'll take a look at the sample and make sure it can be used as published.

Regards,
 
Hmm, it looks like I forgot to actually add the message filter. No excuses,
it is just getting late I guess. Hopefully the code works for you after
adding the following statement (eg in the form's constructor):
ApplicationEx.AddMessageFilter (new MessageFilter)

Again I have not tested it and I am not a VB person, but hopefully it gives
you a start.

Regards,
 
I decided to quickly test the code, of course I found another error, but
here is a working snippet:

Again, make sure to add the Microsoft.WindowsCE.Forms reference.


Imports System
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.Data
Imports OpenNETCF
Imports OpenNETCF.Drawing
Imports OpenNETCF.Windows.Forms

Public Class Form1
Inherits System.Windows.Forms.Form
Private mainMenu1 As System.Windows.Forms.MainMenu

Public Sub New()
InitializeComponent()

ApplicationEx.AddMessageFilter(New MessageFilter)

End Sub

Protected Overloads Sub Dispose(ByVal disposing As Boolean)
MyBase.Dispose(disposing)
End Sub

Private Sub InitializeComponent()
Me.mainMenu1 = New System.Windows.Forms.MainMenu
Me.Menu = Me.mainMenu1
Me.Text = "Form1"
End Sub

Shared Sub Main()
ApplicationEx.Run(New Form1)
End Sub
End Class


Public Class MessageFilter
Implements IMessageFilter

Public Function PreFilterMessage(ByRef m As
Microsoft.WindowsCE.Forms.Message) As Boolean Implements
IMessageFilter.PreFilterMessage
If m.Msg = WinMsg.WM_HELP Then
OpenNETCF.Diagnostics.Process.Start("peghelp.exe", "test.htm")
Return True
End If
Return False
End Function
End Class
 
you could download the OpenNETCF library and take out whatever you want, it
comes with the source !
 
As Lloyd points out, you can just get our source and use it. I don't think
there's a way to do it other than the way we've implemented. Sure, you
could change method and variable names, but you're still going to have to
create a message pump and use it to look for the message. Why would you
want to rewrite that when it's already done?
 
Back
Top