locked
How can a window in a dialog receive keyboard message? RRS feed

  • Question

  • How can a window in a dialog receive keyboard message?

    I create a window in a dialog.This window can show 3D drawing including rotation and can receive mouse message,but it can not receive keyboard message.

    Please tell me why,Thank you for your answer.My code for create window is as follow.Maybe it need more parameter.

    My program for create window is as follow:

    R2=CRect(200, 600, 1000, 800);

    // TODO: Add extra initialization here
    m_pDisplay1->Create( NULL, //CWnd default
    NULL, //has no name
    WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE,
    R2,
    this, //this is the parent
    u1);

    Monday, December 5, 2005 6:36 AM

Answers

  • A window can get keyboard messages, when it has the focus. Only one window at  a time can have the input focus.
    If the window is visible you can transfer the focus to a window in using SetFocus.

    Usually in a dialog windows sets the focus to the first control with the WS_TABSTOP style. Use WS_TABSTOP as a style. Use SetFocus in OnInitDialog and return with FALSE from OnInitDialog.
    Monday, December 5, 2005 7:34 AM