tags:

views:

55

answers:

3

This may be a long short or not even possible but no harm in asking.

What I am trying to do is monitor an application for any new windows it creates in its MDI control. I have implemented hooking in C# and can capture the MDICREATE window message but because I need to get information about the window after is has been created the MDICREATE message isn't much help because at that stage the window hasn't been created in the other application yet.

Without going into to much detail I just need to be able to see when a new window has been created.

Is this possible?

Thanks

+1  A: 

I'm not aware of another message that gets the info that you are looking for off hand. But if that message works for you, you could hook that message and then do another scan of the windows to find the one you are missing. You can enumerate the child windows of the parent window. Use Spy++ to see the exact window hierarchy.

Brian R. Bondy
A: 

If you can watch for a particular function call, I would use some kind of hooking library to grab that (EasyHook comes to mind).

You can hook the MDI create function (assuming there is one), watch for that, then inn your code, call the original and do any lookups using the returned value. You'll have access to the returned value and any parameters, so you should be able to get some info out of those.

peachykeen
A: 

Two options off the top of my head.

  1. Hook the WM_MDIACTIVATE event, the first time the window is being activated, use a flag to determine the first time the window is being activated.

  2. If you need to run your code after the WM_MDICREATE or WM_MDIACTIVATE, you can post a new custom message from one of these messages, which is then handled after these messages have completed. You then write your code to handle the custom message.
Chris Taylor