Can I send / receive window messages without a window?

I am writing a .NET wrapper around an old MFC-based library. It is based on a class that sends notifications using window messages; it has a function that allows the user to pass a handle to the window, and this window will receive messages.

I could just require that my shell users be in a subclass Controland pass in their control descriptor to receive messages, but this is terrible. I want my wrapper class to have events that fire when the old library sends a message, and then I can make the decoding of the message something reasonable. But I do not want my wrapper class to be a control.

Is there a way to create a 'dummy' window handle and receive messages sent to this handle without creating a window?

+3
source share
3 answers

There is a MessageOnly Windows concept that can help you. You can create only the inner window only in your wrapper class and pass this handle to the old library.

+9
source

You can try to create a stream using the message pump and send your messages to it. Then the stream generates any necessary events that you want to process in C # code.

0
source

, , - , Windows, WS_VISIBLE . MFC- ( ;)). (++) CWnd, , . , #, .

-1

Source: https://habr.com/ru/post/1709518/


All Articles