SendMessage()、WPARAM、LPARAM函数使用例子(转)

时间:2021-10-10 05:59:43

  http://chujiaba.blog.163.com/blog/static/18991813720106209350592/

2010-07-20 21:35:00|  分类:
C |  标签: |举报 |字号大中小 订阅

1.传两个参数
(1)#define WM_FREE_USERLINE WM_USER+102
(2)CWnd *view=(CWnd *)m_wndList->GetParent();
   view->SendMessage(WM_FREE_USERLINE,1,(LPARAM)this);//找空闲外线
(3)afx_msg UINT GetFreeLine(WPARAM wParam,LPARAM lParam);
(4)ON_MESSAGE(WM_FREE_USERLINE,GetFreeLine)
(5)UINT CPhoneHelperView::GetFreeLine(WPARAM wParam,LPARAM lParam)
{

 PhoneLine *pline=(PhoneLine *)lParam;
 int type=wParam;
.......
}
2.传两个参数
(1)#define WM_DIAL WM_USER+103
(2)char dtmf[200];
dtmf[strlen(dtmf)-1]='\0';
......
view=(CWnd *)m_wndList->GetParent();
view->SendMessage(WM_DIAL,(WPARAM)dtmf,(LPARAM)this);
(3)afx_msg UINT DoDial(WPARAM wParam,LPARAM lParam);
(4)ON_MESSAGE(WM_DIAL,DoDial)
(5)UINT CPhoneHelperView::DoDial(WPARAM wParam,LPARAM lParam)
{
 // AfxMessageBox("OK");
 
 PhoneLine *pline=(PhoneLine *)lParam;
 
 char *dial_num=(char *)wParam;
......
}
3.一个参数
(1)#define WM_WEB_DIAL WM_USER+104
(2)handle->SendMessage(WM_WEB_DIAL,0,(LPARAM)&webdial);

struct WebDial
{
 int in_line;
 char cmd[4];
 char telnum[20];
 char msg[4];
 SOCKET webSocket;
    SOCKADDR_IN addrFrom;
 char recorFileName[1000];
 char projectName[300];
};
 
struct WebDial webdial;

memset(&webdial,0,sizeof(struct WebDial));
webdial.in_line=theApp.pUserIPandID->Id;
webdial.webSocket=m_socket;
webdial.addrFrom=addrFrom;
(3)afx_msg UINT DoWebDial(WPARAM wParam,LPARAM lParam);
(4)ON_MESSAGE(WM_WEB_DIAL,DoWebDial)
(5)UINT CPhoneHelperView::DoWebDial(WPARAM wParam,LPARAM lParam)
{
 struct WebDial *webdial=(struct WebDial *)lParam; 
......
}