CJ7
CJ7

Reputation: 23295

How should application be using ForegroundLockTimeout registry value?

If an application invokes and activates another application there can be the issue of the invoked application not being brought to the foreground.

One work-around is to set the HKCU\Control Panel\Desktop\ForegroundLockTimeout registry value to 0 instead of the default 200000 milliseconds.

How should an application be controlling this registry value? Would it be feasible to temporarily change it to achieve the work-around and then change it back?

Upvotes: 4

Views: 16860

Answers (1)

Hans Passant
Hans Passant

Reputation: 942119

Hacking the registry on the fly is never an acceptable workaround. If an application owns the foreground window then it won't have any trouble activating the window of another application. It can be done explicitly with the AllowSetForegroundWindow() winapi function. The linked MSDN page also lists the exact rules. Also helps to find the SPI_SETFOREGROUNDLOCKTIMEOUT argument for the SystemParameterInfo function.

There's a dirty undocumented hack to break the rules. I won't go into great detail about it, other than mentioning that it is actually used in the .NET framework. Since most of your questions are .NET questions I'll assume it applies, you can use Microsoft.VisualBasic.Interaction.AppActivate() method.

Upvotes: 7

Related Questions