Re: PostMessage() Error
- From: "David Webber" <dave@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Feb 2007 16:37:57 -0000
<one2001boy@xxxxxxxxx> wrote in message
news:%23IQMQtpVHHA.3568@xxxxxxxxxxxxxxxxxxxxxxx
is there a way to send a string using PostMessage()?
int status;
unsigned char c, s[90] = "message to be sent";
c = s[0];
// the following works
status = PostMessage(hwnd, WM_CHAR, c, 1L);
// the following doesn't work
status = PostMessage(hwnd, WM_CHAR, s, strlen(s));
Correct. I presume you have defined the buffer s[] locally within the
function. Which means it will no longer exist when the function exits.
Some time later the handler of the message will look where it was (at the
address pointed to by s) and find garbage.
If you understand what strings are (ie that s is a pointer to a buffer
containing room for 90 characters) and what "going out of scope" means then
this will come as no surprise, and numerous solutions will present
themselves. Otherwise there is no magic answer. :-(
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
.
- Follow-Ups:
- Re: PostMessage() Error
- From: Igor Tandetnik
- Re: PostMessage() Error
- References:
- PostMessage() Error
- From: one2001boy@xxxxxxxxx
- PostMessage() Error
- Prev by Date: Re: Changing file names in VS projects.
- Next by Date: LoadLibrary path problem
- Previous by thread: Re: PostMessage() Error
- Next by thread: Re: PostMessage() Error
- Index(es):
Relevant Pages
|