我自己开发了个图书管理系统,用到了listview控件,还有组合框控件,我在点击listview一条item时,会有void CBRBook::OnClickListBorrowmember(NMHDR* pNMHDR, LRESULT* pResult) 这个函数响应,我想在这个函数中发一条消息CBN_EDITCHANGE给组合框控件,我是这么做的
::SendMessage(((CComboBox*)GetDlgItem(IDC_R_MEMBER))->GetParent()->GetSafeHwnd(),WM_COMMAND,CBN_EDITCHANGE,0);
但是组合框的此消息响应函数没有处理此消息,百度也找不到解决办法,谢谢。
void CBRBook::OnClickListBorrowmember(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int memselect = m_list_Bmember.GetSelectionMark();
CString memname;
memname = m_list_Bmember.GetItemText(memselect,1);
if(mflag == BORROW_STATE)
{
m_BR_member.SetWindowText(memname);
}
else
{
((CComboBox*)GetDlgItem(IDC_R_MEMBER))->SetWindowText(memname);
//SendMessage(CBN_EDITCHANGE,0,0);如何发消息????
::SendMessage(((CComboBox*)GetDlgItem(IDC_R_MEMBER))->GetParent()->GetSafeHwnd(),WM_COMMAND,CBN_EDITCHANGE,0);
}
*pResult = 0;
}
void CBRBook::OnEditchangeBrMember()
{
// TODO: Add your control notification handler code here
mflag = BORROW_STATE;
//删除会员列表以前的信息
m_list_Bmember.DeleteAllItems();
UpdateData(TRUE);
//获取会员信息
CString member;
m_BR_member.GetWindowText(member);
//会员信息空处理
if(member == _T(""))
{
m_list_Bmember.DeleteAllItems();
return;
}
//会员部分信息匹配度
/*
if(CB_ERR == m_BR_member.FindString(-1,member))
{
return;
}*/
ADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
//显示可以借阅图书的会员信息
CString sql;
sql.Format("select * from Tab_member where booknum < 3 and Mem_name like '%%%s%%'",member);
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet((_bstr_t)sql);
//int num = m_pRecordset->RecordCount;
int i = 0;
while(m_pRecordset->adoEOF == 0)
{
m_list_Bmember.InsertItem(i,"");
m_list_Bmember.SetItemText(i,0,(char*)(_bstr_t)m_pRecordset->GetCollect("Mem_id"));
m_list_Bmember.SetItemText(i,1,(char*)(_bstr_t)m_pRecordset->GetCollect("Mem_name"));
m_list_Bmember.SetItemText(i,2,(char*)(_bstr_t)m_pRecordset->GetCollect("Facuty"));
m_list_Bmember.SetItemText(i,3,(char*)(_bstr_t)m_pRecordset->GetCollect("Sex"));
m_list_Bmember.SetItemText(i,4,(char*)(_bstr_t)m_pRecordset->GetCollect("Grade"));
m_list_Bmember.SetItemText(i,5,(char*)(_bstr_t)m_pRecordset->GetCollect("booknum"));
m_pRecordset->MoveNext();
i++;
}
m_AdoConn.ExitConnect();
}
::SendMessage(((CComboBox*)GetDlgItem(IDC_R_MEMBER))->GetParent()->GetSafeHwnd(),WM_COMMAND,MAKEWPARAM(IDC_R_MEMBER,CBN_EDITCHANGE),0);