Re: PostMessage() Error
one2001boy@yahoo.com wrote:
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));
You can put anything you want into parameters accompanying WM_CHAR
message. PostMessage will dutifully deliver them to the window procedure
of the target window. However, said window proc will interpret these
values according to the documentation - character code in wParam, flags
in lParam. The second call you show basically sends garbage.
You can of course send a series of WM_CHAR messages, each carrying a
single character.
What are you trying to achieve? State your problem, not a proposed
solution that doesn't work. Chances are, there are better ways to
proceed.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925