Specjalistyczne rozwiązania informatyczne

Restore minimized application

I needed to bring to front minimized application from code. I've found, that I need:

Application->Restore()
SetForeGroundWindow(Handle)

It doesn't work. Application blinks on taskbar, but it's not bringing back to front. Since Win2k/XP we have to attach to current's focused thread to steal focus:

Application->Restore();
AttachThreadInput(GetWindowThreadProcessId(hCurWnd, NULL),GetCurrentThreadId(), true);
SetForegroundWindow(Handle);
AttachThreadInput(GetWindowThreadProcessId(hCurWnd, NULL),GetCurrentThreadId(), false);

   © KLASTER 2017