Thanks, yes, I looked into GetForegroundWindow. It works. It gives me a handle of type CWnd*. So now my question is how do I use it? I need to know the CWnd* type handles of my open windows so I can compare to know which one is on top but I can't find a way to do that. Can you provide an example?