0

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.

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
AKJ
  • 65
  • 1
  • 6
  • 2
    I googled it for you, here's the [documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/bb776884%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396). I started googling "suggestions" and so forth, but ended up googling "autocomplete". Finding information is an indispensable skill so I suggest you train on that: it will help you much more than any concrete answer to concrete question. – Cheers and hth. - Alf Apr 12 '16 at 06:22

1 Answers1

3

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).

IInspectable
  • 46,945
  • 8
  • 85
  • 181
  • Hi, I have added the code you suggested. But I am not getting any output. code is as below, CWnd *pCBEdit = myCOmbo.GetDlgItem(1001); HWND h_handle = pCBEdit->GetSafeHwnd(); if (SUCCEEDED(SHAutoComplete(h_handle,SHACF_FILESYS_DIRS ))) AfxMessageBox(L"DOne"); Message box appears. I want to show all the avaialable folers when user types "C:\". DO I have to add all the possible folders into some structure and show it on the call of method?. I am using combobox. – AKJ Apr 13 '16 at 07:01
  • @AKJ Your casting is wrong. And you should use an Edit box, not ComboBox. Or use ComboBoxEx, read the link for information. – Barmak Shemirani Apr 13 '16 at 09:06