views:

1822

answers:

1

I'm making an application where I interact with each running application, right now, I need a way of getting the windows zorder, for instance, if firefox and notepad are running, I need to know which is the must upfront... Any ideas ? (basides doing this for each application mainWindow I also need to do it for it's childs and sisters (windows belonging to the same process) windows)

Best Regards, Jose

+3  A: 

You can use the GetTopWindow function to search all child windows of a parent window and return a handle to the child window that is highest in z-order. The GetNextWindow function retrieves a handle to the next or previous window in z-order.

GetTopWindow: http://msdn.microsoft.com/en-us/library/ms633514(VS.85).aspx
GetNextWindow: http://msdn.microsoft.com/en-us/library/ms633509(VS.85).aspx

NineBerry
And the "desktop" should able to be used as the parent window by specify null for the parent. Hence you can easily get the top level window on the desktop.
Software Monkey