Solved

Activate/BringToFront/SetForegroundWindow/SwitchToThisWindow our application

Posted on 2009-07-15
7
4,025 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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