Solved

Activating a window from another process in NT 4.0

Posted on 1997-10-29
2
259 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
[X]
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
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

717 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