0

I'm working on a problem (How to Detect a form open inside the application) and stumbled over a Windows Message I can't understand: 0xC052.

This is the first Message I receive in a MessageFilter when a form opens. But since I didn't found any reference I don't want to rely on the assumption, that the message tells me reliable that a form was opened.

EDIT: Added code

Application.AddMessageFilter(new MessageFilterImpl());

class MessageFilterImpl : IMessageFilter
{
    public bool PreFilterMessage(ref Message m)
    {
        Control wnd = Form.FromHandle(m.HWnd);
        if (wnd is Form)
            knownForms.Add((Form)wnd); //m.Msg is 0xC052

        return false;
    }
}
Community
  • 1
  • 1
Patrik
  • 1,355
  • 12
  • 22
  • That sounds like something broadcasted from another application you have installed - it's not a standard message. In any case, what you're looking for is the `Load` event, I think. – Luaan Sep 21 '15 at 07:59
  • Thanks. But to add an event handler to the `Load`-event I'd need to know the `form` in the first place, which is the initial problem. – Patrik Sep 21 '15 at 08:01
  • It may be an Unicode of any character. –  Sep 21 '15 at 08:02
  • Why should a unicode-character be the message-code inside the message-loop? – Patrik Sep 21 '15 at 08:03

1 Answers1

1

Assuming this is a well-formed windows message, it's a dynamically allocated ID returned from the RegisterWindowMessage function (note the range 0xC000-0xFFFF). The function is used when you need to define a new windows message that's supposed to be system-unique. In other words, you can't rely on the ID - it will be different the next time you reboot.

.NET Winforms uses it internally plenty of times - it's a well behaving windows application framework. So the exact number you found might conceivably correspond to something like:

  • A thread callback (Invoke and friends)
  • Mouse enter message
  • Get control name (Name)

And of course, it doesn't even have to be a .NET message - there might be some application on your system that broadcasts messages to all forms, for example. It's a common way of handling RPC (in my case, the form received e.g. MSUIM.Msg.RpcSendReceive).

Luaan
  • 62,244
  • 7
  • 97
  • 116