I know all the reasons why it is a bad idea. I dislike it if an application steals input focus, but this is for purely personal use and I want it to happen; it will not disturb anything.
(for the curious: I am running unit tests in NetBeans, which generate a log file. When my background application sees the log file’s timestamp change I want it to parse the log file and come to the front to show the results).
This question did not help, nor did googling. It seems that BringToFront() hasn’t worked for a long time and I can’t find any alternative that does.
Any ideas?
You can’t do this reliably. Windows XP had a workaround that would allow it, but versions since then prohibit it for the most part (see note below). This is expressly stated in the remarks section of the MSDN documentation on
SetForegroundWindow:Note the final paragraph of the quoted documentation, especially the first sentence.
The problem with
is that any application could try to do the same thing. How does “purely personal use” tell it’s you personally and not just any application? 🙂
Note: I’ve tried everything I can think of to get the IDE’s documentation to show in the foreground when I click the help toolbutton, but all I can get is the flashing taskbar button (and I as the user want it to do so).