Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I send / receive window messages without a window?

I'm writing a .NET wrapper around an old MFC-based library we have. It's based around a class that sends notifications using window messages; it has a function that lets the user pass in a handle to a window, and that window will receive the messages.

I could just require the users of my wrapper to subclass Control and pass their control's handle in order to receive messages, but that's horrible. I want my wrapper class to have events which fire whenever the old library sends a message, and then I can do the decoding of the message into something sensible. But, I don't want my wrapper class to have to be a control.

Is there a way for me to create a 'dummy' window handle, and receive the messages sent to that handle, without creating a window?

like image 688
Simon Avatar asked Jan 23 '23 13:01

Simon


1 Answers

There is a concept of MessageOnly Windows which can help you. You may create an internal message only window in your wrapper class and pass this handle to the old library.

like image 68
Canopus Avatar answered Jan 30 '23 09:01

Canopus