In C++, plain win32 programming (NO MFC) what message is sent to the textfield's callback if the textfield's text changes? Basically, i need to know how to detect changes in the text of a textfield. Please help.
Printable View
In C++, plain win32 programming (NO MFC) what message is sent to the textfield's callback if the textfield's text changes? Basically, i need to know how to detect changes in the text of a textfield. Please help.
If by textfield you mean an edit control, you want to handle the EN_CHANGE message.
Yes i meant an edit control, however the en_change message seems to be evoked only if i cut text from the edit control and not if i type inside the edit control during runtime.Any other suggestions?
Wrong! you should notificaiton also during text writing.Quote:
Originally Posted by blastingblast
Cheers
No its still not working for me. This is my callback function for the edit control.What am i doing wrong? Is the en_change given to the parent or something? Here is the callback.
LRESULT CALLBACK NewProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_LBUTTONDBLCLK:
....
break;
case EN_CHANGE:
MessageBox(0,L"text has changed",L"text has changed",0);
break;
case WM_KEYUP:
....
break;
case WM_MOUSEMOVE:
........
break;
}
return CallWindowProc(OldProc ,hwnd,msg,wParam,lParam);
}
please mention if there is any way to capture changes in text through the edit controls callback
CheersCode:case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_EDIT1: //Edit ID
{
if (HIWORD(wParam) == EN_CHANGE)
::MessageBox(0, "EN_CHANGE", "IDC_EDIT1", MB_OK);
break;
}
}
break;
blastingblast, notice that the snippet golanshahar gave you show you an important detail about window messages.
It's not a coincidence that they start with something like WM_, EN_, SC_ and so on. The first letters of the symbol indicate what group it belong to i.e. whenever you see a message that not start with WM_ you can be sure it's not handled directly in the message switch and that you have to read more about it on MSDN... ;)
Yeah i finally got it. Thanks guys. I made 2 mistakes
1) tried to check en_change in edit control's callback and not the form's
2) tried checking en_change in the message rather than in the wparam
Though this is all i need, if there is a way to detect changes in the edit control's callback instead of the form's,let me know.
Thanks for all the help.