Link to home
Start Free TrialLog in
Avatar of cosie
cosie

asked on

very easy question...

how to activate a win32 app???
I start myapp, then start onother app, and I want to bring to front myapp after one minites...
I've tried SetForgroundWindow, but it only flashes the myapp's icon on the taskbar, but did not puts myapp to the front, and set the focus to it. How to do that?
Avatar of jkr
jkr
Flag of Germany image

Have you tried 'BringWindowToTop()'?
Avatar of mblat
mblat

or SetWindowPos(.....) ?
ASKER CERTIFIED SOLUTION
Avatar of ambience
ambience
Flag of Pakistan 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
ambience,
    just out of curiosity: How did you come across that function? I mean, this is nothing that you do stumble into when doing 'normal' business. After all, it's undocumented probably for the reason to keep people from using it ;)
    kudos to those people that do not fear reverse engineering in this day and age of evergrowing complexity of computer systems and os's.

cosie,
    like ambience already said, the behaviour you are experiencing is meant to work this way. This is a security feature. If you read through the MSDN description that tells you what conditions have to be met to get SetForegroundWindow to work, you will quickly see why it is implemented the way it is. To give you an example: Let's assume your screen saver asks the user to enter the password when it returns, this could result in a potential security hazard. Some virus-like application running in the background could intercept that system message, call SetForegroundWindow to gain input focus, have the unsuspecting user type his/her password and save it. In general, the user should be in absolute control over which application has the input focus any given time. That's why the SetForegroundWindow-fxn has been 'disabled' on win nt systems >=5.0.
i found a mention of it on web somewhere, but cant remember the link (was quite long ago) ...
Avatar of cosie

ASKER

W2k test results:
SwitchToThisWindow(hWnd, TRUE) for the app itself worked only with 2nd param set to false, anyway worked only, if the app was minimized. (So I had to add a SetWindowState and SetFocus)

If I called it from an outofprocess exe component, the same effect occured.

If I called it from another process, which had the focus, it worked regardless the second param...

Interesting, but who cares?

Thanx, pal.