-1

I want to be notified when user click the password text field. enter image description here But when I do click the password text field, the following function is called more than once:

void CUserDlg::OnSetfocusPasswordEdit()
 {
 // TODO: Add your control notification handler code here
    cout << "focus on password text field";
 }

Why does this happen ? I also tried :

LRESULT CFakeUserDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{

// TODO: Add your specialized code here and/or call the base class
switch (message)
{
  case WM_COMMAND:
    switch (LOWORD(wParam))
    {
        case IDC_PASSWORD_EDIT:
        if (HIWORD(wParam) == EN_SETFOCUS)
        {
            cout << "";
            
        }
        cout << "";
        break;
    }
    .
    .
    .

This also happens many times when I click the text field only once.

I just tried to spy++, but it shows that spy++ caputure edit control messages, but EN_SETFOCUS is not message, it is edit control notification.

Community
  • 1
  • 1
firstaccount
  • 155
  • 2
  • 13
  • There's not enough information here to answer your question. What have you tried in order to debug it? Have you used Spy++ to check the message stream and see if there are actually multiple WM_SETFOCUS messages happening or maybe you've got a bug somewhere else that makes the code think it's happening multiple times. – Adrian McCarthy Jan 10 '17 at 21:28
  • Not WM_SETFOCUS – firstaccount Jan 10 '17 at 21:46
  • Right, sorry. EN_SETFOCUS notifications, which you could also check with Spy++. – Adrian McCarthy Jan 10 '17 at 22:24
  • I just tried to spy++, but it shows that spy++ caputure edit control messages, but EN_SETFOCUS is not message, it is edit control notification. – firstaccount Jan 11 '17 at 00:42
  • I thought Spy++ had a way to watch for particular notifications as well, but I can't find that setting now, so maybe I'm misremembering. What else have you tried to debug this? – Adrian McCarthy Jan 11 '17 at 01:07
  • I tried to use the same function(OnSetfocusPasswordEdit) for a fully functional application, it also has the same problem. So I guess it is not because "maybe you've got a bug somewhere else that makes the code think it's happening multiple times.", it must related to the WindowProc function, maybe I didn't use correct judgment condition . – firstaccount Jan 11 '17 at 01:21

1 Answers1

-1

I got answer by myself. Edit control does keep sending EN_SETFOCUS when it gets the focus.

firstaccount
  • 155
  • 2
  • 13