How to SetFocus on a CEdit box so that the user can just start typing when the dialog loads?

Posted on 2006-04-04
Last Modified: 2008-02-01
Hello everyone,

I have a dialog that opens when a user opens my application asking them for their username/password. I want to have the focus set on the USERNAME CEdit box when the dialog loads so that the user doesn't have to click on the USERNAME box to type in their text.

The focus should be set on load so they can just type in their name.

How can I do this? Any comments or pointing in the right direction is appreciated.
Question by:VirtueTech
    LVL 86

    Expert Comment

    The easiest way - set that CEdit as the initially focused (default) control for that dialog using the resource editor.

    Author Comment

    I don't see a way to set it as the initially focused control.

    Is this in the CEdit box's properties?

    Sorry for the newb question
    LVL 48

    Accepted Solution

    In dialog editor Select Layout - Tab Order in the menu and click dialog controls in desired order. First should be this edit box.
    BTW, setting focus programmatically is done using GotoDlgCtrl function.

    Author Comment

    Wow...that was cool..and pretty easy. Thanks.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Article by: SunnyDark
    This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
    This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now