MFC Edit Box - Multiple Characters Per Key Press?

I am trying to create a simple dialog in MFC using Visual C ++. My problem is that when I get the dialog on screen and try to enter the "Edit Field" field, if I type the letter "a" once, it appears in the edit field as "aaaaaaaaaaa" (that's 12 a). Also, if I try to navigate in the window using the arrow keys, the carat moves 12 characters at a time.

This is not just a display error, as the output from the edit box is still "aaaaaaaaaaaa".

I would post the code, but not actually post anything. I added an edit box using the toolbar in Visual Studio and assigned a variable to it in my class, so this is not any special edit box.

If anyone has any thoughts about what might happen it will be very helpful. Unfortunately, I don't know where to start.

Thanks as always.

+1


source to share


5 answers


Are you capturing any events like WM_KEYUP in your PreTranslateMessage () function, or elsewhere in your application?



If you've overridden the default handling for keyboard events, it might cause the symptoms you see.

0


source


To debug this, add the PreTranslateMessage function to your dialog and see how many times the keydown is processed.



BOOL DialogName::PreTranslateMessage(MSG* pMsg)
{

    if(pMsg->message==WM_KEYDOWN)
    {
        // TODO: see what is going on here
        return TRUE; //do not dispatch this message, so keydown will have no effect
    }

    return CDialog::PreTranslateMessage(pMsg);
}

      

+1


source


For some reason, this brings back vague memories of the early battles with MFC. Have you ever looked for mutual recursion? I was always doing something in the same application that sent a message (unknown to me) that was picked up by another method that called the first method ...

My guess is one of those who hit the forehead; it gives me this nagging feeling of déjà vu that I can't make concrete.

If it is mutual recursion, you should be able to see it in the call stack if you can find the right place for the breakpoint.

0


source


Is this happening for a new project, or can you recreate this issue in a new project? This will help determine if it was something you did in your code or your installation.

0


source


I installed Service Pack 2 on my WinXp 64 OS and the issue resolved for me :)

0


source







All Articles