Solved

Get Message WM_ACTIVATE External Process

Posted on 2009-04-07
9
1,150 Views
Last Modified: 2013-12-03
How i can get an event or windows messages in my application, when a external process's window is activate.
0
Comment
Question by:ISIGest
[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
  • 3
  • 3
  • 3
9 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 24089153
You can do that using a WH_GETMESSAGE hook that filters for that mesage. See http://msdn.microsoft.com/en-us/library/ms997537.aspx ("Win32 Hooks") and http://www.swissdelphicenter.ch/torry/showcode.php?id=1212 for a Delphi example.
0
 
LVL 2

Expert Comment

by:mannujam
ID: 24094117
WM_KILLFOCUS message is sent to a window immediately before it loses the keyboard focus
0
 

Author Comment

by:ISIGest
ID: 24098692
Thanks, but i need to hook "many" forms of a single external process...how i can do it?
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 86

Expert Comment

by:jkr
ID: 24098768
Well, as the above article explains - to set a global hook (i.e. one that is notified about every message sent to any window), implement the hook proc in a DLL and call 'SetWindowsHookEx()' with the DLL' module handle and a NULL thread ID. In pseudocode, that would be

HINSTANCE hInst = LoadLibrary("myhook.dll");

HOOKPROC pProc = GetProcAddress(hInst,"MyHook");

SetWindowsHookEx(WH_GETMESSAGE,pProc,hInst,0);
0
 
LVL 2

Expert Comment

by:mannujam
ID: 24103981
As JKR told you can get all MSg for the associated window and then you can refine the message from the message queue. BUT If SetWindowHookEx last parameter is 0 , it will be hooking the message for all of the windows currently running. If this parameter is zero, the hook procedure is associated with all existing threads running in the same desktop as the calling thread.

So their you can put the thread id for your "single external process"

0
 

Author Comment

by:ISIGest
ID: 24105364
Thanks a lot. I like it and i think that is my solution...can you post a simple program to do this?
0
 

Author Comment

by:ISIGest
ID: 24105790
I've found a solution like this but in VB, can anyone help me to translate it to Delphi language:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_21083100.html
0
 
LVL 2

Expert Comment

by:mannujam
ID: 24106617
Not aware of delphi  :(
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 24107527
Well, I posted a Delphi example already - see http://www.swissdelphicenter.ch/torry/showcode.php?id=1212
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
TEMBEDDEDWB how can i change its user agent ? 8 83
egit plugin on eclipse 8 96
What namespace do I need to import? 2 48
Delphi, TImage, Png 2 19
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
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…

740 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