views:

763

answers:

5

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

It's not just a display error, as the output from the editbox is still "aaaaaaaaaaaa".

I'd post code, but there's really none to post. I added the edit box using the Toolbox in Visual Studio and assigned a variable to it in my class so this isn't any sort of special edit box.

If anyone has any thoughts as to what might be happening it would be greatly appreciated. Unfortunately, I don't know where to begin.

Thank as always.

A: 

For some reason this brings back vague memories of early struggles with MFC. Have you looked for mutual recursion at all? I was forever doing something in one bit of the app that sent a message (unbeknown to me) that was picked up by another method that called the first method...

My guess is it's one of those smack the forehead ones; it gives me this nagging sense of deja vu that I can't make concrete.

If it's mutual recursion you should be able to see it in the call stack, if you can find the right place for a break point.

mr calendar
A: 

Are you capturing any events such as WM_KEYUP in your PreTranslateMessage() function or anywhere else in your app ?

If you have overridden the default handling for keyboard events, it might cause the symptoms you are seeing.

Adam Pierce
A: 

Is this happening for a fresh project, or can you recreate this problem in a fresh project? It'll help discern whether it's something you've done in your code, or your install.

Mark Essel
+1  A: 

To debug this, add PreTranslateMessage function to your dialog, and see exactly how many times the keydown is being 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);
}
rec
A: 

I installed service pack 2 in my WinXp 64 OS and the problem get solved for me :)

Johny Joseph