Hi.

I'm trying to trap WM_SETTEXT messages using system hooks and all
seems to be going well with the hooking process (i.e. I get the
messages and they correspond to the same messages I see in Spy++,) but
for the life of me I cant figure out how to get at the string: "lParam
- Pointer to a null-terminated string that is the window text." All
attempts to strlen(lParam) or strcpy(lParam) just cause havoc.

I regularly work with the .NET framework, but most of my C/C++
experience is very rusty and was very unix-centric to begin with. I'm
assuming that I'm missing something here, like having to marshal the
string across processes (the messages are being snatched from another
process) or having to envelope the whole copying affair in a critical
section or perhaps even just using different APIs than the good ol'
stdio.h stuff.

Can anyone shed any light on this for me? It seems like "getting the
text" from a message should be a fairly straightforward task.

Thanks,
Ian

Re: How to get text from message WM_SETTEXT, etc by David

David
Mon May 10 10:49:41 CDT 2004


"Ian" <ipmccun@hotmail.com> wrote in message
news:e8736d76.0405100448.2bdc45d9@posting.google.com...

> I'm trying to trap WM_SETTEXT messages using system hooks and all
> seems to be going well with the hooking process (i.e. I get the
> messages and they correspond to the same messages I see in Spy++,)
but
> for the life of me I cant figure out how to get at the string:
"lParam
> - Pointer to a null-terminated string that is the window text."
All
> attempts to strlen(lParam) or strcpy(lParam) just cause havoc.

The "LPARAM lParam" is of the wrong type. If LPARAM is
representing a pointer to a string then use

LPCTSTR(lParam)

(LPARAM is a way to pass a 4 byte quantity of arbitrary type which
gets round C++' strict type definition rules - you have to know what
it is and cast it.)

Dave
--
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm