I\'m using SetForegroundWindow API in .NET using PInvoke.
When I use the API while debugging in Visual Studio its works perfectly. But it doesn\'t work always when
David was right and led me to the right direction . Followed the code project article which says "The system automatically enables calls to SetForegroundWindow if the user presses the ALT key or takes some action that causes the system itself to change the foreground window"
How to bring window to top with SetForegroundWindow()