TABSTOP controls

I'm having trouble moving around my Win32 app with the TAB key. I'm using only the windows pre-existing registered classes.

When I press TAB, I can select the button, but it never goes to the edit boxes.

The format is something like this:
1
2
3
4
5
6
7
8
9
10
Parent Window
|-> Group Box 1
|   |-> Edit Box 1
|   |-> Radio Button 1
|   |-> Radio Button 2
|-> Group Box 2
|   |-> Edit Box 2
|   |-> Radio Button 3
|   |-> Radio Button 4
|-> Button 1


My boxes, buttons and group boxes are created like so:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void EditBox::Create(int Xpos, int Ypos, int Xsize, int Ysize, HWND parent, int ident)
{
  hwnd = CreateWindow("Edit", NULL, WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP, Xpos, Ypos, Xsize, Ysize, parent, (HMENU)ident, NULL, NULL);
}
void GroupBox::Create(std::string text, int Xpos, int Ypos, int Xsize, int Ysize, HWND parent, int ident)
{
  hwnd = CreateWindowEx(0, "Button", text.c_str(), WS_CHILD | WS_VISIBLE | BS_GROUPBOX, Xpos, Ypos, Xsize, Ysize, parent, (HMENU)ident, NULL, NULL);
}
void Button::Create(std::string text, int Xpos, int Ypos, int Xsize, int Ysize, HWND parent, int ident, bool def)
{
  DWORD style = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
  if (def) style |= BS_DEFPUSHBUTTON;
  hwnd = CreateWindowEx(0, "Button", text.c_str(), style , Xpos, Ypos, Xsize, Ysize, parent, (HMENU)ident, NULL, NULL);
}


I tried adding WS_TABSTOP to the group-box and I do see a difference (The button is only selected every 3rd TAB stroke), but I can't get the cursor to appear in any of the edit boxes.

In my main loop I do check IsDialogMessage():
1
2
3
4
5
6
7
8
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
  if (!IsDialogMessage(hwnd, &Msg))
  {
    TranslateMessage(&Msg);
    DispatchMessage(&Msg);
  }
}


Any ideas?
I don't know of a better way to do it, but I've got it working.

The answer was to put all of my edit boxes in the main window. This means that if anything in my main window is selected when I hit TAB, it'll go to the next object in my main window that has WS_TABSTOP.

The disadvantage is that I can't just move around group boxes easily anymore since the coordinates of the edit boxes are now relative to the top left pixel of the main window instead of the group-box that it is in.

My new Parent-Child tree now looks like this, which is less convenient
1
2
3
4
5
6
7
8
9
10
Parent Window
|-> Group Box 1
|   |-> Radio Button 1
|   |-> Radio Button 2
|-> Group Box 2
|   |-> Radio Button 3
|   |-> Radio Button 4
|-> Edit Box 1
|-> Edit Box 2
|-> Button 1


I'm guessing that I'd have to make a customer class and register it if I want to send messages such as WM_KEYDOWN: VK_TAB to the parent window. If anyone has any other ideas. I am very happy to listen!
Topic archived. No new replies allowed.