Solved

Activate/BringToFront/SetForegroundWindow/SwitchToThisWindow our application

Posted on 2009-07-15
7
4,047 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now