Use IMessageFilter From a VB .NETCF Project

I posted this to the newsgroup earlier, but figured it was a useful thing to post for future reference. If you want to implement a custom IMessageFilter using OpenNETCF.Windows.Forms.ApplicationEx you have to be aware that VB.NET autogenerates a main proceedure for you if your project startup object is a form. Therefore it will use the Application.Run method and your filter will never be used. Instead you can implement a Sub Main as your startup object and use ApplicationEx:-

Public Shared Sub Main()

ApplicationEx.Run(New MyFormType())

End Sub


Then set your Startup object in project properties to your new Sub Main rather than the name of your form class.