Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 604527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:02:54+00:00 2026-05-13T17:02:54+00:00

I have a window with 10 child edit controls in it. I would like

  • 0

I have a window with 10 child edit controls in it. I would like to move from one edit control to other by pressing the tab key – how do I do this?

I mean, even if I could find out whether I pressed the tab-key, how do I find the next edit control to focus into? I hope I do not have to keep track of the edit controls myself as I already added them to the parent window.

PS: by “next” I mean the order I created the edit controls…

Edit: I’m on Win32 using plain C.

Edit 2: sample



#include 

#define NAME "test"

LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    HWND edit1, edit2;
    switch (msg)
    {
        case WM_CREATE:
            edit1 = CreateWindow("edit", "", WS_CHILD|WS_VISIBLE, 0, 0, 200, 50, hWnd, NULL, NULL, NULL);
            edit2 = CreateWindow("edit", "", WS_CHILD|WS_VISIBLE, 250, 0, 200, 50, hWnd, NULL, NULL, NULL);
            return 0;

        case WM_CLOSE:
            DestroyWindow(hWnd);
            return 0;

        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    }
    return DefWindowProc(hWnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASS wc;
    wc.style = 0;
    wc.lpfnWndProc = WinProc;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = hInstance;
    wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    wc.lpszMenuName = NAME;
    wc.lpszClassName = NAME;
    RegisterClass(&wc);

    HWND win;
    win = CreateWindow(NAME, "test", WS_OVERLAPPEDWINDOW, 0, 0, 500, 500, NULL, NULL, hInstance, NULL);

    ShowWindow(win, nCmdShow);
    UpdateWindow(win);

    MSG msg;
    while(GetMessage(&msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:02:54+00:00Added an answer on May 13, 2026 at 5:02 pm

    The dialog manager does a lot of this for you, so if you don’t have a good reason for creating your own window class, you might consider creating a dialog instead.

    If you’re still of a mind to roll your own, you’ll have to intercept WM_CHAR and look for VK_TAB and VK_SHIFT | VK_TAB. The dialog manager uses something called “z-order” as the tab order (http://msdn.microsoft.com/en-us/library/ms632599%28VS.85%29.aspx#zorder).

    FWIW, my advice would be to not underestimate the burden you’re taking on when trying to re-create an existing facility in Windows like this. For every behavior that you know about, there are usually at least as many that you don’t. For example, how will your application behave on a pen-based device? What about accessibility extensions? Will screen readers be able to handle it properly? All of that stuff is already baked into the dialog manager.

    I’m not sure I followed… I thought
    dialogs are just a floating windows
    above the “regular” (?) one. Is it
    possible that the application uses
    just a dialog, instead of proper
    CreateWindow()?

    Dialogs can be modal or modeless children of the main application window, but they can also be the main application window. That’s typically called a dialog-based app.

    If you want a dialog-based application (that is, an application with a dialog as it’s main window), you’d do something like this:

    int WINAPI WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow )
    {
        MSG msg;
        HWND hDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DialogProc);
        if (hDlg != NULL)
        {
            ShowWindow(hDlg, SW_SHOWNORMAL);
    
            while (GetMessage(&msg, NULL, 0, 0)) {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
            }
        }
        return 0;
    }
    

    The full example is probably too long to list here, but if you Google for CreateDialog, you should find some examples of this.

    …And is it possible to
    add other windows inside a dialog?
    Even with custom window procedures?
    (In other words, in dialogs, am I not
    restricted just to the default
    controls, like edit and static?)

    Yes, you can create custom controls within the dialog. Within the DIALOG portion of your .rc file, you can include something like:

    CONTROL "",IDC_MYCUSTOM,"MyCtrlClassName",WS_TABSTOP,10,20,30,40
    

    You can also create a new control and add it to the dialog dynamically (I’ll let you Google for an example).

    Also, if I wanted to roll my own, how
    do I find out what’s the next control?
    I don’t really think there will be
    more use cases than a basic desktop

    Use GetNextDlgTabItem() if you want to cycle through the controls within a dialog in tab-order: http://msdn.microsoft.com/en-us/library/ms645495%28VS.85%29.aspx

    If you’re rolling your own, then you probably want something like the EnumChildWindows() function: http://msdn.microsoft.com/en-us/library/ms633494%28VS.85%29.aspx

    This may also be useful: http://msdn.microsoft.com/en-us/library/bb775501%28VS.85%29.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a window with an edit control as its child. The control is
If I have a Xaml Window, how does one open it as a child
I have a Window where I have put a Frame. I would like to
In my child window I have $('#opfile').addOption(someval,sometext); Problem is #opfile is an a parent
Hi I have an MDI application where a child window handles a number of
I have a Windows service(C#), that sprawns few child native processes (C++). I'd like
I have a window (derived from JFrame) and I want to disable the close
I have a window with 2 column grid. Left column contains a browser control
I have enabled blur on my window. I have some edit fields and some
I have this little function function makewindows(){ child1 = window.open (about:blank); child1.document.write(<?php echo htmlspecialchars(json_encode($row2['ARTICLE_DESC']),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.