Hi
Trying to dig into the win32 api from my WPF application (which just runs through the systray).
When clicking on the systray icon, I present the user with a contextmenu, which gains focus over whatever window was topmost.
I want to get a handle to that window (the one, that just lost focus) and have tried with different approaches using
GetForeGroundWindow()
GetTopWindow()
GetDesktopWindow()
To no end however. I'm currently considering iterating through all processes, to get the MainWindowHandles and checking the z-order of each and every window.
But I reckoned that there's an easier/smarter way; simply just one I cannot google or recall from my old Petzold tome.
Another way would be for my systray menu not to gain focus when activated?
Thanks!