MFC自定义消息

来源:互联网 发布:烟雾视频软件 编辑:程序博客网 时间:2024/05/16 19:45

#define WM_MYMSG WM_USER+8

使用类向导添加自定义消息 很多人说MFC自定义消息 不可以用类向导 上个图

ON_MESSAGE(WM_MYMSG, &CmodalessDlg::OnClist)

消息响应

afx_msg LRESULT CmodalessDlg::OnClist(WPARAM wParam, LPARAM lParam){CListCtrl* p = (CListCtrl*)GetDlgItem(IDC_LIST1);//取ListCtrl IDCString* pStr = (CString*)lParam;//LPARAM转换成CString指针CString str;str.Format("%s", pStr);//指针转换成字符串p->InsertItem(p->GetItemCount(),"1");//ListCtrl增加一行p->SetItemText(0, wParam, str);//添加内容到表return 0;}