Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Activating Applications

Posted on 2002-07-24
2
266 Views
Last Modified: 2013-12-03
I'm trying to get my application to activate itself, to produce the same effect as clicking on its button in the taskbar.

However, I've tried all of the following APIs, and none of them seem to achieve this effect:

SetActiveWindow
SetForegroundWindow
SetWindowPos
BringWindowToTop
SetFocus

How is this supposed to be done?
0
Comment
Question by:scce
2 Comments
 
LVL 8

Accepted Solution

by:
fl0yd earned 100 total points
ID: 7176240
Did you try

::ShowWindow( hWnd, SW_RESTORE );
::SetForegroundWindow( hWnd );

? This probably won't work on win2k for security reasons. The call to SetForegroundWindow will be replaced by the sequence SetActiveWindow/FlashWindowEx. I haven't tried it myself, but the MSDN states a long list of conditions that need to be met in order for SetForegroundWindow to work as expected.
0
 

Author Comment

by:scce
ID: 7178769
Hi fl0yd,

Thanks for the comment and the pointer to the msdn article, it explained everything.  You were right, when I used SetForegroundWindow I was just getting a taskbar flash (using XP).

I was actually trying to activate the app in response to a call from its Help File via a custom DLL.  So, now I get the DLL (under the foreground thread from the Help File) to activate it before I send the notification message.

Easy!  Thanks again.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

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