?
Solved

Activating Applications

Posted on 2002-07-24
2
Medium Priority
?
281 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 400 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

864 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