Handling keyboard input on a dialog - Windows
<p>I am programming an application that is non-modal dialog based. I am using the Visual Studio resource editor to build the dialog and create the application. Everything is going great so far. However, I have reached a brick wall when it comes to handling keyboard input. My research has shown that windows captures keyboard input before it reaches the dialog callback procedure to implement the ability to move the focus using the keyboard. </p>

<p>I created a bare bones dialog to test this and, when I have a dialog without any controls on it, everything works as I would expect it to. When I add a control, it stops working. </p>

<p>Here is the code from the bare bones project:</p>

<pre><code>#include &lt;Windows.h&gt;
#include &lt;CommCtrl.h&gt;
#include &lt;tchar.h&gt;
#include "resource.h"

INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM  lParam);
HWND dlghandle;
int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE h0, LPTSTR lpCmdLine, int nCmdShow)
{
HWND hDlg;
MSG msg;
BOOL ret;


hDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DIALOG1), 0, DialogProc, 0);
ShowWindow(hDlg, nCmdShow);
dlghandle = hDlg;
while ((ret = GetMessage(&amp;msg, 0, 0, 0)) != 0) {
    if (ret == -1)
        return -1;
    if (!IsDialogMessage(hDlg, &amp;msg))
    {
        TranslateMessage(&amp;msg);
        DispatchMessage(&amp;msg);
    }
}
return 0;
}

INT_PTR CALLBACK DialogProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
    switch (uMsg)
{
case WM_KEYDOWN:
    MessageBox(NULL, L"Test", L"Test", MB_OK);
    break;
case WM_CLOSE:
    DestroyWindow(hDlg);
    break;
case WM_DESTROY:
    PostQuitMessage(0);
    return 0;
    break;
}
return 0;
}
</code></pre>

<p>What options do I have? </p>