I want to set Auto complete property to my Combobox. For that iam use SHAutoComplete API of windows.I know this api is used for Instructs system edit controls to use AutoComplete to help complete URLs or file system paths. To set autocomplete to combbox, iam use edit control inside the combobox has a control ID 1001. Use the GetDlgItem() function with this ID to get the handle of the edit control. the code section is below.
CWnd* pEditCombo = m_Combo.GetDlgItem( 1001 );
if( pEditCombo )
HRESULT hRes = SHAutoComplete( pEditCombo->m_hWnd, SHACF_FILESYSTEM );
if( S_OK != hRes )
AfxMessageBox( _T( "Failed" ));
here m_Combo is the object of CComboBox. But when execute the program SHAutoComplete API return fail. why?
The discussion from the comments section leads to the solution:
A common error is forgetting to call
AfxOleInit(). One of these must be called before using functions from COM libraries like
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)