How do I create a message-only window from windows forms?

后端 未结 4 887
梦如初夏
梦如初夏 2021-01-21 08:26

I\'m trying to create a message-only window to receive window messages from an MFC library class, within a winforms application.

I\'ve tried subclassing NativeWind

4条回答
  •  温柔的废话
    2021-01-21 08:41

    I fear that you must derive from a Form, and force the window invisible.

    Another approach (in the case the class library is modifiable) is to run a message pump without a window (see Application.Run and Application.AddMessageFilter, or if you prefer pinvokes using PeekMessage & Co).

    In this case you can send messages using PostThreadMessage by having the thread id which as run Application.Run, but actually you cannot synch with the application message pump thread because it doesn't wait message acknowledge.

提交回复
热议问题