【发布时间】:2019-05-21 08:16:14
【问题描述】:
我正在从 VistaCredentialProviderSamples 运行 SampleWrapExistingCredentialProvider,并且在 CSampleCredential.cpp 文件中有一个名为“SetComboBoxSelectedValue”的函数。当用户更改组合框中的选定项并存储选定项索引时调用此函数但是,当我在运行时使用 AppendFieldComboBoxItem 函数在组合框中附加一个项目时,如果选择了附加项,则不调用此函数.因此,我无法获取附加字段的选定项目索引。
我试图显示一个消息框以查看何时调用此函数。仅当用户选择了默认组合框项之一时才调用此函数,而不是在选择附加项时调用。
// Called when the user changes the selected item in the combobox. We'll check to see if
// it's for us or the wrapped credential, and then handle or route it as appropriate.
HRESULT CSampleCredential::SetComboBoxSelectedValue(
DWORD dwFieldID,
DWORD dwSelectedItem
)
{
HRESULT hr = E_UNEXPECTED;
// Make sure we have a wrapped credential.
if (_pWrappedCredential != NULL)
{
// If this field belongs to the wrapped credential, hand it off.
if (_IsFieldInWrappedCredential(dwFieldID))
{
hr = _pWrappedCredential->SetComboBoxSelectedValue(dwFieldID, dwSelectedItem);
}
// Otherwise determine if we need to handle it.
else
{
FIELD_STATE_PAIR *pfsp = _LookupLocalFieldStatePair(dwFieldID);
if ((pfsp != NULL) && (dwSelectedItem < ARRAYSIZE(s_rgDatabases)))
{
_dwComboIndex = dwSelectedItem;
HWND hwndOwner = nullptr;
if (_pCredProvCredentialEvents)
{
_pCredProvCredentialEvents->OnCreatingWindow(&hwndOwner);
}
TCHAR msg[100];
StringCbPrintf(msg, 100, TEXT("%d"), _dwComboIndex);
MessageBox(hwndOwner, msg, TEXT("Combobox selected ID"), MB_OK | MB_ICONERROR);
hr = S_OK;
}
else
{
hr = E_INVALIDARG;
}
}
}
return hr;
}
我还需要检测附加字段的组合框选定项索引。关于如何检测附加组合框项目的索引的任何帮助将不胜感激?
【问题讨论】:
标签: c++ winapi combobox credential-providers