16,472
社区成员
发帖
与我相关
我的任务
分享
BOOL CXXDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_COMMAND == pMsg->message)
{
if(CBN_DROPDOWN == HIWORD(pMsg->wParam) && IDC_COMBO1 == LOWORD(pMsg->wParam))
{
AfxMessageBox(_T("DOWN"));
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
// Add 10 items to the combo box.
CString strItem;
for (int i = 0; i < 10; i++)
{
strItem.Format(_T("item %d"), i);
m_pComboBox->AddString(strItem);
}
// Verify the 10 items were added to the combo box.
ASSERT(m_pComboBox->GetCount() == 10);
CComboBox::GetCount
int GetCount( ) const;
Return Value
The number of items. The returned count is one greater than the index value of the last item (the index is zero-based). It is CB_ERR if an error occurs.
Remarks
Call this member function to retrieve the number of items in the list-box portion of a combo box.
Example
// The pointer to my combo box.
extern CComboBox* pmyComboBox;
// Add 10 items to the combo box.
CString str;
for (int i=0;i < 10;i++)
{
str.Format(_T("item %d"), i);
pmyComboBox->AddString( str );
}
// Verify the 10 items were added to the combo box.
ASSERT(pmyComboBox->GetCount() == 10);