Solved

Activating Applications

Posted on 2002-07-24
2
262 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
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

12 Experts available now in Live!

Get 1:1 Help Now