Solved

Activate/BringToFront/SetForegroundWindow/SwitchToThisWindow our application

Posted on 2009-07-15
7
4,086 Views
Last Modified: 2012-05-07
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.
0
Comment
Question by:TelDig
  • 3
  • 2
  • 2
7 Comments
 
LVL 30

Expert Comment

by:flubbster
ID: 24862910
Have you tried the SetFocus() command?
0
 
LVL 30

Expert Comment

by:flubbster
ID: 24862936
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
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 24863113
The "...some other time it's blinking orange" bit throws up a red flag for me.

This behaviour sounds like the "prevent applications from stealing focus" feature of the Operating System itself.  Instead of apps taking the focus, they instead blink either indefinitely or for a configured number of times in the taskbar.  These setttings are stored in the registry.  The easiest way to change these settings are through Microsofts Tweak UI utility.

Download the Tweak UI tools from Microsoft:
http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

Or do it manually:
http://www.pctools.com/guides/registry/detail/540/
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:TelDig
ID: 24863282
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)
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24863384
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....
0
 

Author Closing Comment

by:TelDig
ID: 31603924
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
0
 

Author Comment

by:TelDig
ID: 24868540
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)
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question