CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2008
    Posts
    26

    how to detect changes in text in a textfield

    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.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: how to detect changes in text in a textfield

    If by textfield you mean an edit control, you want to handle the EN_CHANGE message.

  3. #3
    Join Date
    Apr 2008
    Posts
    26

    Re: how to detect changes in text in a textfield

    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?

  4. #4
    Join Date
    May 2005
    Posts
    4,954

    Re: how to detect changes in text in a textfield

    Quote Originally Posted by blastingblast
    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.

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  5. #5
    Join Date
    Apr 2008
    Posts
    26

    Re: how to detect changes in text in a textfield

    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

  6. #6
    Join Date
    May 2005
    Posts
    4,954

    Re: how to detect changes in text in a textfield

    Code:
    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;
    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  7. #7
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: how to detect changes in text in a textfield

    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...

  8. #8
    Join Date
    Apr 2008
    Posts
    26

    Smile Re: how to detect changes in text in a textfield

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured