Hi Peter, By the "winner", actually I was referring to solution from Francois Piette. I only added a little more details. But since currently I have idle hands, I will write you a small demo project.
Okay, attached is the quick demo project. But note that what the demo does quite is the opposite of what you want. The demo only detects if the mouse is over ANY windows belong to the demo application. The reason is because in the quick demo the hook can only intercept windows messages sent to the application. So it can not intercept mouse messages sent to windows belonged to other applications. So the demo's primary goal is only to shows you how to do windows hooking. But if you read the code carefully, you will see that all you have to do is to add 'NOT' in front of "MouseIsOverOurOwnWindow" in line 71 to get what you want. To intercept mouse messages sent to windows of other applications you have to do the hooking and handling the messages inside a dll. Being inside a dll, now your code can be "smuggled" into any application space. So you have to move the MouseHookHandler routine, the hooking (line 81) and unhooking (line 86) lines, and the notification PostMessage in line 72 to a dll. Note for hooking, you have to change into "MouseHook := SetWindowsHookEx(WH_MOUSE, MouseHookHandler, HINSTANCE,0);" if you do the hooking inside a dll. Best regards, Luthfi --- On Mon, 10/25/10, Peter Kapas <pka...@sbcglobal.net> wrote: > From: Peter Kapas <pka...@sbcglobal.net> > Subject: Re: Recognition ov application window > To: "Moderated List for the Discussion of Delphi Programming > excludingDatabase-related topics" <delphi@elists.org> > Date: Monday, October 25, 2010, 11:47 AM > Hi Luthfi, > > May I ask you for small example. What you advised to me, > seems be really the "winner". Only I am not > familiar with that type of programing. I found something on > Greatis' WinDowse program under "Window". > It is the "Process ID". If I can get this info, how to > program it, it will be 1000% enough for that, what I am > looking for. > > Thanks, > Peter > > ----- Original Message ----- From: "Betta International" > <betta_...@yahoo.com> > To: "Moderated List for the Discussion of Delphi > Programming excludingDatabase-related topics" <delphi@elists.org> > Sent: Sunday, October 10, 2010 4:21 AM > Subject: Re: Recognition ov application window > > > Hi Peter, > > After a quick look to Win32 SDK, I think you already have > the winner here. After you install a mouse hook (see > SetWindowsHookEx - WH_MOUSE) your application will get > notifications in the form of this record: > > typedef struct tagMOUSEHOOKSTRUCT { > POINT pt; > HWND hwnd; > UINT wHitTestCode; > DWORD dwExtraInfo; > } > > "pt" tells you the coordinate of the mouse, and "hwnd" > tells you window handle that is receiving the mouse message > (i.e. directly under the cursor). Now you can check if "pt" > is within your application windows territory or not. If so, > you then you check if hwnd is your window or not (compare > result from win32 api GetWindowThreadProcessId of that hwnd > against your application process id). > > > Regards, > Luthfi B Hakim > > --- On Sat, 10/9/10, Peter Kapas <pka...@sbcglobal.net> > wrote: > > > From: Peter Kapas <pka...@sbcglobal.net> > > Subject: Re: Recognition ov application window > > To: Delphi@elists.org > > Date: Saturday, October 9, 2010, 9:16 PM > > Hi Francois, > > > > Thanks, I already tried it. There are a few standard > mouse > > functions to simplify that, > > but the major problem is, when the application window > is > > partly covered by the other > > Windows applications and I cannot mask the area to say > "I > > do not see > > my application, set-up indicator to False, if for > seeing > > that is True). > > --- > > Peter > > --------------------------- > > > I would like to find method how to recognize, > the > > mouse is over my > > > application window. If that window is partly > covered > > by other application, > > > I want to recognize that situation, in other > words, > > that time, I want see > > > some indicator, which tells me, between mouse > cursor > > and my application > > > window is something. How to do it? (I am using > > Delphi 4). > > > > Just an idea, not tested. > > Install a mouse hook to get the mouse movements > whatever > > application is > > above your's. Then knowing the area(s) where you > > application is, you can > > compute if the mouse is within or not, even if your > app is > > behind another > > other one.
_______________________________________________ Delphi mailing list Delphi@elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi