5 class CEnumString :
public IEnumString {
8 CEnumString(
const t_data & in) : m_data(in) {m_walk = m_data.first();}
11 void AddString(
const TCHAR * in) {
12 m_data.insert_last()->set_data_fromptr(in, _tcslen(in) + 1);
13 m_walk = m_data.first();
15 void AddStringU(
const char * in,
t_size len) {
19 m_walk = m_data.first();
21 void AddStringU(
const char * in) {
25 m_walk = m_data.first();
27 void ResetStrings() {m_walk.invalidate(); m_data.remove_all();}
31 COM_QI_ENTRY(IUnknown)
32 COM_QI_ENTRY(IEnumString)
35 HRESULT STDMETHODCALLTYPE Next( ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched) {
36 if (rgelt == NULL)
return E_INVALIDARG;
38 while( done < celt && m_walk.is_valid()) {
39 rgelt[done] = CoStrDup(m_walk->get_ptr());
42 if (pceltFetched != NULL) *pceltFetched = done;
43 return done == celt ? S_OK : S_FALSE;
46 static TCHAR * CoStrDup(
const TCHAR * in) {
47 const size_t lenBytes = (_tcslen(in) + 1) *
sizeof(TCHAR);
48 TCHAR * out =
reinterpret_cast<TCHAR*
>(CoTaskMemAlloc(lenBytes));
49 if (out) memcpy(out, in, lenBytes);
53 HRESULT STDMETHODCALLTYPE Skip(ULONG celt) {
55 if (m_walk.is_empty())
return S_FALSE;
61 HRESULT STDMETHODCALLTYPE Reset() {
62 m_walk = m_data.first();
66 HRESULT STDMETHODCALLTYPE Clone(IEnumString **ppenum) {
67 *ppenum =
new TImpl(*
this);
return S_OK;
73 class CACList_History :
public CEnumString {
78 HRESULT STDMETHODCALLTYPE Reset() {
82 for(
const char * walk = state;;) {
84 t_size len = (next != NULL) ? next - walk : ~0;
85 AddStringU(walk, len);
86 if (next == NULL)
break;
90 return __super::Reset();
93 HRESULT STDMETHODCALLTYPE Clone(IEnumString **ppenum) {
94 *ppenum =
new TImpl(*
this);
return S_OK;
105 hr = CoCreateInstance(CLSID_AutoComplete, NULL, CLSCTX_ALL, IID_IAutoComplete, (
void**)ac.
receive_ptr());
107 PFC_ASSERT(!
"Should not get here - CoCreateInstance/IAutoComplete fail!");
return hr;
109 hr = ac->Init(edit, vals, NULL, NULL);
111 PFC_ASSERT(!
"Should not get here - ac->Init fail!");
return hr;
117 PFC_ASSERT(!
"Should not get here - ac->QueryInterface fail!");
return hr;
119 hr = ac2->SetOptions(opts);
121 PFC_ASSERT(!
"Should not get here - ac2->SetOptions fail!");
return hr;
129 acl->AddStringU(*valueEnum); ++valueEnum;
136 acl->AddStringU(*valueEnum); ++valueEnum;
143 acl->AddStringU(valueEnum->
ptr()); ++valueEnum;
153 static_cast<CEnumString*
>(theList)->AddStringU( item );
162 for(
const char * walk = values;;) {
164 if (next == NULL) {acl->AddStringU(walk, ~0);
break;}
165 acl->AddStringU(walk, next - walk);
172 var.
on_init(comboBox, initVal);
173 COMBOBOXINFO ci = {}; ci.cbSize =
sizeof(ci);
174 if (!GetComboBoxInfo(comboBox, &ci)) {
175 PFC_ASSERT(!
"Should not get here - GetComboBoxInfo fail!");
const t_item * get_ptr() const
::pfc::const_iterator< t_item > const_iterator
t_size estimate_utf8_to_wide(const char *p_in)
void CreateACList_AddItem(IUnknown *theList, const char *item)
Differences between chain_list_v2_t<> and old chain_list_t<>: Iterators pointing to removed items as...
pfc::com_ptr_t< IUnknown > CreateACList(pfc::const_iterator< pfc::string8 > valueEnum)
t_size convert_utf8_to_wide(wchar_t *p_out, t_size p_out_size, const char *p_in, t_size p_in_size)
Converts UTF-8 characters to wide character.
void set_size(t_size p_size)
t_size convert_utf8_to_wide_unchecked(wchar_t *p_out, const char *p_in)
Simple implementation of a COM reference counter. The initial reference count is zero, so it can be used with pfc::com_ptr_t<> with plain operator=/constructor rather than attach().
HRESULT InitializeEditAC(HWND edit, pfc::const_iterator< pfc::string8 > valueEnum, DWORD opts)
HRESULT InitializeSimpleAC(HWND edit, IUnknown *vals, DWORD opts)
void on_init(HWND ctrl, const char *initVal)
HRESULT InitializeDropdownAC(HWND comboBox, cfg_dropdown_history_mt &var, const char *initVal)