Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem with repeat count of keyboard input (win 32)

Hi ,

I've created a modeless DialogBox as main window using
"CreateDialogParam(...)" with an Edit control. When I type in from keyboard , each single character automatically gets repeated 4 times.
I tried to trap WM_KEYDOWN and WM_CHAR message in WndProc of DialogBox but it does not seem to receive these messages.

Please help me in turning off this AutoRepeat feature.

Thanks a lot

Comments

  • weiccoweicco Posts: 950Member
    : Hi ,
    :
    : I've created a modeless DialogBox as main window using
    : "CreateDialogParam(...)" with an Edit control. When I type in from keyboard , each single character automatically gets repeated 4 times.
    : I tried to trap WM_KEYDOWN and WM_CHAR message in WndProc of DialogBox but it does not seem to receive these messages.
    :
    : Please help me in turning off this AutoRepeat feature.
    :
    : Thanks a lot
    :

    Windows send always WM_KEYDOWN message to every window when key is pressed (and window is active of course). I don't quite remember how the messaging system works but I think if you try to intercept those messages from DialogBox it doesn't work. You should override Edit control's wndproc or something. If you are using MFC this should be easy.

    But I think you should find out the reason why characters duplicates. Is your keyboard repeat delay too short?

  • vibhavibha Posts: 7Member
    : : Hi ,
    : :
    : : I've created a modeless DialogBox as main window using
    : : "CreateDialogParam(...)" with an Edit control. When I type in from keyboard , each single character automatically gets repeated 4 times.
    : : I tried to trap WM_KEYDOWN and WM_CHAR message in WndProc of DialogBox but it does not seem to receive these messages.
    : :
    : : Please help me in turning off this AutoRepeat feature.
    : :
    : : Thanks a lot
    : :
    :
    : Windows send always WM_KEYDOWN message to every window when key is pressed (and window is active of course). I don't quite remember how the messaging system works but I think if you try to intercept those messages from DialogBox it doesn't work. You should override Edit control's wndproc or something. If you are using MFC this should be easy.
    :
    : But I think you should find out the reason why characters duplicates. Is your keyboard repeat delay too short?
    :

    My program works fine if I create a modal DialogBox using DialogBox(..) or Window using CreateWindow(...) .

    Any suggestions ???


  • AsmGuru62AsmGuru62 Posts: 6,519Member
    MFC or not MFC?

    On more serious note - I never heard of such trick! I am curious myself, because I love unusual bugs... Can you post a code here or ar 'codexxi@accessv.com'?

  • vibhavibha Posts: 7Member
    : MFC or not MFC?
    :
    : On more serious note - I never heard of such trick! I am curious myself, because I love unusual bugs... Can you post a code here or ar 'codexxi@accessv.com'?
    :

    Problem was in this code to handle message dispatching

    while (GetMessage(&msg, NULL, 0, 0))
    {
    if (IsDialogMessage(hDlg, &msg))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    }

    MSDN HELP says
    Because the IsDialogMessage function performs all necessary translating and dispatching of messages, a message processed by IsDialogMessage must not be passed to the TranslateMessage or DispatchMessage function.
    The correct code will be:

    if (! IsDialogMessage(hDlg, &msg))
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }

    Thanks AsmGuru62



  • AsmGuru62AsmGuru62 Posts: 6,519Member
    What is it can be done in custom dialog class which cannot be done in a standard dialog class?


  • brigsoftbrigsoft Posts: 58Member
    Yes,
    WM_KEYDOWN sends to window that has focus.
    Focus is on child window (edit control)
    You can get Child window ID, after - handle.
    Make your WinProc for this window
    and work with it.

    Alex
    http://www.brigsoft.com

    : Hi ,
    :
    : I've created a modeless DialogBox as main window using
    : "CreateDialogParam(...)" with an Edit control. When I type in from keyboard , each single character automatically gets repeated 4 times.
    : I tried to trap WM_KEYDOWN and WM_CHAR message in WndProc of DialogBox but it does not seem to receive these messages.
    :
    : Please help me in turning off this AutoRepeat feature.
    :
    : Thanks a lot
    :


Sign In or Register to comment.