Link to home
Start Free TrialLog in
Avatar of TelDig
TelDigFlag for Canada

asked on

Activate/BringToFront/SetForegroundWindow/SwitchToThisWindow our application

We have two application (A and B) sending "messages" to each other in A there is a button that send a message to the B application that can be minimized or behind the other. When B get this message the application should be bring to front and be activated. The current code was a SetForegroundWindow

We have tryed many solution/combination of solution and cannot find any working solution:
SetForegroundWindow / SetActiveWindow / SwitchToThisWindow ...
but can't find any combination that work on my dev machine or other machine. Sometime it simply didn't work, some other time it's blinking orange.

Anyone know how to do it?

Currently we cannot change any code in A but can fix in B with our entry point.
Avatar of flubbster
flubbster
Flag of United States of America image

Have you tried the SetFocus() command?
This article (first section) has some good info also on making sure that the active thread is correct for the window you are calling.

http://www.microsoft.com/msj/0397/Win32/Win320397.aspx
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TelDig

ASKER

Idle Mind:
It's effectively caused by the "prevent applications from stealing focus"
but is there a work around that will only affect my application?

I cannot change the registry and affect all other applications of all users! It should have a way to do it like the TaskManager does?

Flubbster:
we are calling the activate from the UI thread (sound good)
What would be the point of that feature if an application could easily exclude itself from the system wide setting?...it's supposed to put the USER back in control...not the programmer.   =\

Wish I had a better answer for you....
Avatar of TelDig

ASKER

Yah! But would be nice if at least a user can configure this behavior only for our applications instead of a system wide feature ;o)
Thanks
Avatar of TelDig

ASKER

It's still strange that my computer is working fine even it the 'ForegroundLockTimeout' is set to default values (0x30b40).
And setting to 0 in the test computer fix the issue ;o)