tags:

views:

39

answers:

1

I've created my controls in my window in the WM_CREATE message like this:

case WM_CREATE:
{
    CreateWindowA("button", "Refresh Listview",
                  BS_MULTILINE | WS_CHILD | WS_VISIBLE, 10, 10, 70, 50,
                  hwnd, (HMENU)IDC_REFRESHLW, g_hInst, NULL);
    break;
}

When I press tab it does nothing, do i have to initialize it somehow?

I noticed if I use a dialog, it already automatically has tabbing initialized and the tab order is the order in which you create the controls in the .rc file.

But i don't want a dialog!

thanks

+1  A: 

To get tabbing to work on a dialog you need to build a call to IsDialogMessage into your message loop.

Your message loop should look something like:

HWND hwnd; // main window handle

MSG msg;
while(GetMessage(&msg,0,0,0)>0)
{
  if(!IsDialogMessage(hwnd,&msg))
  {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
}

IsDialogMessage works by examining the message and seeing if its a VK_TAB or related message - it then looks at the hwnd passed in to see which of its child windows has focus, and, if a child window has focus, searches for other child windows with the WS_TABSTOP style, and moves focus to the next TABSTOP enabled control on the window. The window does NOT have to be a dialog to use this function, merely have child windows that can accept focus, and have the WS_TABSTOP style.

Chris Becke
wow, thanks. works perfect. I saw this call once, but i thought it could only be used if your using a dialog. thanks a lot!