🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to catch mouseclicks from another application?

#10458
From: Henk
Date: Fri, 09 Apr 2004 06:49
49 lines
3130 bytes
> The hook DLL is injected into the address space of every application(s)
that
> you are hooking.  Unless the calling application currently has focus, it
> can't bring any windows into focus.  This way whatever the user is
currently
> doing is not interrupted.
>
> It could also be caused your use of a static HWND, since every DLL
instance
> is going to get its own local copy of the HWND, but you are only setting
the
> HWND for the DLL instance that is loaded by your own application.  If you
> look at the function's return value, I will bet you that it is reporting
an
> invalid handle.  To share an HWND (or anything else, for that matter)
> between all of the instances of your DLL, you need to store the data in
> shared memory.  Look at the CreateFileMapping() and MapViewOfFile()
> functions for that.

You're right about getting an invalid handle.

>but you are only setting the HWND for the DLL instance that is loaded by
your own application

I understand, of course, but should that be a problem with my application?
As to me I think I don't use more than this one instance being loaded by my
application. Am I right?

So I tried another idea by creating a callback function in my main
application that is called from the DLL's GetMsgProc function.

My callback function type definition:
    typedef void CALLBACK (*MOUSE_EVENT_CALLBACK_FUNCTION)(void)

Inside DLL:
    static MOUSE_EVENT_CALLBACK_FUNCTION MyMouseCallbackFunction;

I first hand over the callback function address to the static DLL variable
'MyMouseCallbackFunction'. This works fine.
Now when I mouseclick OUTSIDE my Borland application the
'MyMouseCallbackFunction' value inside the DLL is NULL.

So again, I still don't get the picture why a system call of  my DLL
'GetMsgProc' function (being the SAME instance, loaded by my application)
looses my static DLL variable values as I thought that STATIC means the
variable is kept alive as long as my application is active. Or do I miss or
mix something?

Henk
Technical Details
Message-ID: <4076476e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!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>

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-08 23:55:18 PST
From: "Henk" <h.van.winkoop@wxs.nl>
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>
Subject: Re: How to catch mouseclicks from another application?
Date: Fri, 9 Apr 2004 08:49:18 +0200
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2727.1300
NNTP-Posting-Host: 62.131.145.60
Message-ID: <4076476e$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1081493358 62.131.145.60 (8 Apr 2004 23:49:18 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail