Solved

Activating a window from another process in NT 4.0

Posted on 1997-10-29
2
227 Views
Last Modified: 2013-12-03
How can I send WM_ACTIVATE window message to another processes' main window to tell it to activate itself in Windows NT 4.0.  I have the process information returned to me from CreateProcess() including the thread ID when I startup the other application.  Nothing I've tried seems to work.
0
Comment
Question by:ghessler
2 Comments
 
LVL 3

Accepted Solution

by:
vinniew earned 100 total points
ID: 1408023
You need to first enumerate all the windows in the desktop with EnumWindows and EnumWindowsProc API calls.  Then, if your application exists more than once, you'll have to associate a window handle with a thread ID (code available at www.ntinternals.com).  Then, when you're sure about the HWND, you can use the SendMessage API and do what you need to do.  

If you want to do this more easily, you could put a global data segment in both programs with something like:

#pragma data_seg("myapplication")
HWND gds_hWindowHandle;
#pragma

Then, in the initialization of the program you created, you could just do a:

gds_hWindowHandle = GetSafeHwnd();


The original program would be in a loop checking for a non-null value of gds_hWindowHandle, and would get it when its filled in.


If you have troubles, post more;

Vinnie

0
 

Author Comment

by:ghessler
ID: 1408024
The enum windows solution worked.  The global handle solution would work if I had control of both applications, but I don't.

Thanks,

Gary
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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