winapi - SendMessage to TextBox Window Child in C++ not working -
char arbc[60]; cout << "message: "; cin.getline(arbc+'\0',sizeof(arbc)+1); system("pause"); postmessage(hwndch,wm_settext,(wparam)*arbc,0);
so hwndch window child , child textbox, it's parent main window form. problem wm_settext isn't setting text of textbox string of characters. know it's not problem windowchild because wm_char outputs @ least 1 character in textbox. note: i'm modifying handles of process.
you cannot use postmessage
wm_settext
. that's synchronous message. problem greater when window in different process. system needs marshal text process process. cannot asynchronous message.
use sendmessage
instead.
your other problems include @ least following:
- the
wparam
argument wrong. parameter ignored. pass(lparam)arbc
lparam
instead. documentation quite clear. - you should not use c strings in case. use
std::string
, ,c_str()
. - your use of
sizeof
wrong. use ofgetline
wrong too. - you seem confused on function calling. title says
sendmessage
, code sayspostmessage
.
you want along these lines:
std::cout << "message: "; std::string msg; std::getline(std::cin, msg); sendmessage(hwndch, wm_settext, 0, (lparam)msg.c_str());
Comments
Post a Comment