Children's process steals focus. How to return it without disturbing the user?

I created a child process from a console application

CreateProcess(NULL, command, NULL, NULL, TRUE, 0, NULL, NULL, &in, &out);

Where

  • commandis the command line for the application I am running in pvw32 img.jpg( pictView to show some image).
  • in is the STARTUPINFO structure (I tried the STARTF_USESHOWWINDOW flag, but you're out of luck, pictView steals focus using some of them).

I tried to give pictView some time and then kindly distract the focus

Sleep(1000);
SwitchToThisWindow(hwnd,TRUE);

I got focus (the cursor blinks again in my console), but the icon on the taskbar blinks several times and the input is not allowed until I press Alt + Tab.

z-, pictView , , . - pictView.

, Alt + Tab?

: simpView, pictView .

+4
1

Remy Lebeau, SetForegroundWindow() . pictView , :

LockSetForegroundWindow(LSFW_LOCK);

, pictView . .

+5

Source: https://habr.com/ru/post/1568373/


All Articles