c++winapimfcdirectoryeditbox

How directory searching in Windows run works?


Here is my requirement.

I am giving one text box, users have to type the folder path. To help the users, when they write the first folder structure say "C:\" into text box,I want to display all the folders available in that path (same way how we get all the directory structure when we use "windows run"). Any code snippet in c++ will be of great help.

Thanks in advance.

AKJ.


Solution

  • The autocomplete feature is built into the shell and available to clients (see Using Autocomplete). Autocomplete can be used with any standard Edit Control. To enable autocomplete just call SHAutoComplete:

    bool EnableAutoComplete(HWND hWndEdit) {
        if (SUCCEEDED(::SHAutoComplete(hWndEdit, SHACF_FILESYS_DIRS)))
            return true;
        return false;
    }
    

    SHAutoComplete allows for a large number of flags to customize the autocomplete behavior. In case none of the options match your requirements, you can implement your custom autocomplete source, and get full control over the suggestions (see How to Enable Autocomplete Manually).