🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #10459

Re: How to catch mouseclicks from another application?

#10459
From: Remy Lebeau (TeamB)
Date: Fri, 09 Apr 2004 07:20
48 lines
3140 bytes
"Henk" <h.van.winkoop@wxs.nl> wrote in message
news:4076476e$1@newsgroups.borland.com...

> I understand, of course, but should that be a problem
> with my application?

Yes.  You are trying to intercept events from an external process, which
means that a separate and independant instance of your DLL must be injected
into that process in order to hook that process.  Setting the HWND for the
instance of the DLL that is injected into your own application will have no
effect on the values of other instances of the DLL that are injected into
other processes.  Thus the need to set asside a block of shared memory so
that they can all share the same HWND and HHOOK values.

> As to me I think I don't use more than this one instance being
> loaded by my application. Am I right?

Your application has an instance loaded, but so does every other process
have its own instance automatically loaded by the OS.

> So I tried another idea

I already told you what you need to do - use shared memory via
CreateFileMapping() and MapViewOfFile().

> by creating a callback function in my main application
> that is called from the DLL's GetMsgProc function.

That will not solve the problem.  That will only effect the DLL instance
that is loaded by your own application.  It will have no effect on the other
instances loaded by other processes at all.

> I first hand over the callback function address to the static
> DLL variable 'MyMouseCallbackFunction'. This works fine.

You are still missing the point.  Static values are NOT global across
multiple processes.  Every process will get its own separate and independant
instance of the DLL loaded, each with its own local variables.  Setting the
variables of one instance will have no effect on the other instances at all.

> Now when I mouseclick OUTSIDE my Borland application
> the 'MyMouseCallbackFunction' value inside the DLL is NULL.

Correct, for the reasons explained above.


Gambit
Technical Details
Message-ID: <40764eac$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <407421ef@newsgroups.borland.com> <40743aad$1@newsgroups.borland.com> <40754399$1@newsgroups.borland.com> <40758801$1@newsgroups.borland.com> <4075a4df$1@newsgroups.borland.com> <4075b6bd$1@newsgroups.borland.com> <4076476e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e0858ea1c0821ca
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-04-09 00:39:28 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <407421ef@newsgroups.borland.com> <40743aad$1@newsgroups.borland.com> <40754399$1@newsgroups.borland.com> <40758801$1@newsgroups.borland.com> <4075a4df$1@newsgroups.borland.com> <4075b6bd$1@newsgroups.borland.com> <4076476e$1@newsgroups.borland.com>
Subject: Re: How to catch mouseclicks from another application?
Date: Fri, 9 Apr 2004 00:20:25 -0700
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.138.253
Message-ID: <40764eac$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081495212 67.22.138.253 (9 Apr 2004 00:20:12 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail