Is it possible to detect when a form opens inside my application?
I have an assembly which is used and initialized by several applications. I need to use this assembly to detect, when a form inside my application opens, to be able to modify it.
The only solution I found, yet, is using a MessageFilter, EDIT: like Most Efficient Way for getting notified on window open - but they ask for windows in all processes where I only want to get the windows in my own process. Since I'm only interested in my own Application/Process I hope to find a sole .NET solution.
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);
return false;
}
}
I found the first Message to receive was 0xC052, but I still didn't find its actual meaning.
The first intention would be to choose a better design, but I'm not allowed to.