PC Review


Reply
Thread Tools Rate Thread

How to override message loop in winforms application

 
 
Felix Collins
Guest
Posts: n/a
 
      27th May 2009
Hi All,
I have a situation where I need to do some custom message filtering.
Unfortunately I need more functionality than provided by the
IMessageFilter system or by overriding a Form's wndproc() method.
What I need is to be able to run code before and after a message is
processed and optionally drop selected messages.

As I understand it:

The IMessageFilter system only allows filtering out selected messages
(can't run code after they have been processed)

A Form's wndproc method only sees messages destined for that form. (I
need to handle all messages for the entire application)

In an unmanaged application say in visual c++ it would be a simple
matter of implementing ones own getmessage/dispatchmessage loop. In
the dotnet framework the actual message loop is implemented in native
code and is inaccessible to the programmer.

Does anyone know a solution for this?

Regards,
Felix
 
Reply With Quote
 
 
 
 
Jesse Houwing
Guest
Posts: n/a
 
      28th May 2009
Hello Felix,

> Hi All,
> I have a situation where I need to do some custom message filtering.
> Unfortunately I need more functionality than provided by the
> IMessageFilter system or by overriding a Form's wndproc() method.
> What I need is to be able to run code before and after a message is
> processed and optionally drop selected messages.
> As I understand it:
>
> The IMessageFilter system only allows filtering out selected messages
> (can't run code after they have been processed)
>
> A Form's wndproc method only sees messages destined for that form. (I
> need to handle all messages for the entire application)
>
> In an unmanaged application say in visual c++ it would be a simple
> matter of implementing ones own getmessage/dispatchmessage loop. In
> the dotnet framework the actual message loop is implemented in native
> code and is inaccessible to the programmer.
>
> Does anyone know a solution for this?


You could host the managed application in a C++ application... That would
allow you access to the Messages for the whole application. It isn't too
hard to host a standard windows forms application inside an unmanaged C++
app.

This should get you started:
http://www.codeproject.com/KB/COM/simpleclrhost.aspx

--
Jesse Houwing
jesse.houwing at sogeti.nl


 
Reply With Quote
 
 
 
 
Jesse Houwing
Guest
Posts: n/a
 
      28th May 2009
Hello Felix,

> Hi All,
> I have a situation where I need to do some custom message filtering.
> Unfortunately I need more functionality than provided by the
> IMessageFilter system or by overriding a Form's wndproc() method.
> What I need is to be able to run code before and after a message is
> processed and optionally drop selected messages.
> As I understand it:
>
> The IMessageFilter system only allows filtering out selected messages
> (can't run code after they have been processed)
>
> A Form's wndproc method only sees messages destined for that form. (I
> need to handle all messages for the entire application)
>
> In an unmanaged application say in visual c++ it would be a simple
> matter of implementing ones own getmessage/dispatchmessage loop. In
> the dotnet framework the actual message loop is implemented in native
> code and is inaccessible to the programmer.
>
> Does anyone know a solution for this?


You could host the managed application in a C++ application... That would
allow you access to the Messages for the whole application. It isn't too
hard to host a standard windows forms application inside an unmanaged C++
app.

This should get you started:
http://www.codeproject.com/KB/COM/simpleclrhost.aspx

--
Jesse Houwing
jesse.houwing at sogeti.nl


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to override message loop in winforms application Felix Collins Microsoft Dot NET Framework Forms 0 27th May 2009 04:22 AM
WinForms, how to override/avoide the tab order for a bunch of buttons/textboxes? Serdge Kooleman Microsoft C# .NET 1 30th Sep 2005 12:29 AM
WinForms, how to override/avoide the tab order for a bunch of buttons/textboxes? Serdge Kooleman Microsoft VB .NET 0 29th Sep 2005 10:03 PM
VC++ 2005 Beta 2: warning C4490: 'override' : incorrect use of override specifier Adriano Coser Microsoft VC .NET 2 28th Jul 2005 01:54 PM
Infinite Loop Infinite Loop Infinite Loop Infinite Loop... Donna Windows XP Setup 0 8th Dec 2003 11:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:51 AM.