资源预览内容
第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
亲,该文档总共8页全部预览完了,如果喜欢就下载吧!
资源描述
添加PreTranslateMessage(MSG* pMsg) 函数可以捕获消息,这里的COMMAND是一个结构体,#define Success 0x01 #define GetDirInfo 0x02 #define ExecFile 0x03 #define GetFile 0x04 #define PutFile 0x05 #define DelFile 0x06 #define DelDir 0x07 #define CreateDir 0x08 #define FileInfo 0x09 #define GetScreen 0x10 #define Getmoses 0x11 #define Lbuttond 0x12 #define Lbuttonu 0x13 #define Rbuttond 0x14 #define Rbuttonu 0x15 #define LbuttonDd 0x16 #define RbuttonDd 0x17 #define MouseWheel 0x18 #define KeyDown 0x19 #define KeyUp 0x20 #define Mbd 0x21 #define Mbu 0x22 #define Mbdd 0x23 typedef struct /命令结构 int ID; /命令ID BYTE lparamBUF_LEN*2; int x; /鼠标xint y; /鼠标y short z; /滚轮 int key; /键盘COMMAND;BOOL CClientView:PreTranslateMessage(MSG* pMsg) / TODO: Add your specialized code here and/or call the base class COMMAND command; if (ifconect!=0) if(m_pRecBMPSocket!=NULL) m_pRecBMPSocket=NULL;/删除原来的套节字m_pRecBMPSocket=new CSocket; m_pRecBMPSocket-Create(); if(!m_pRecBMPSocket-Connect(strtemp,2502) /m_pRecBMPSocket-Send(buf1,30); MessageBox(“连接失败“);delete m_pRecBMPSocket ; m_pRecBMPSocket=NULL; else switch (pMsg-message) case WM_MOUSEMOVE: memset(char*) command.ID=Getmoses; POINT lpPoint; GetCursorPos( command.x=lpPoint.x; command.y= lpPoint.y; /char buf1256; /sprintf(buf1,“%d %d“,command.x, command.y); / AfxMessageBox(buf1); / send(*m_pRecBMPSocket,(char*) m_pRecBMPSocket-Send(char*) break; case WM_KEYDOWN: memset(char*) command.ID=KeyDown; command.key=pMsg-wParam; m_pRecBMPSocket-Send(char*) break; case WM_KEYUP: memset(char*) command.ID=KeyUp; command.key=pMsg-wParam; m_pRecBMPSocket-Send(char*) break;case WM_LBUTTONDOWN: memset(char*)command.ID=Lbuttond; m_pRecBMPSocket-Send(char*) break;case WM_LBUTTONUP: memset(char*) command.ID=Lbuttonu; m_pRecBMPSocket-Send(char*) break;case WM_RBUTTONDOWN: memset(char*) command.ID=Rbuttond; m_pRecBMPSocket-Send(char*) break;case WM_RBUTTONUP: memset(char*) command.ID=Rbuttonu; m_pRecBMPSocket-Send(char*) break;case WM_LBUTTONDBLCLK: memset(char*) command.ID=LbuttonDd; m_pRecBMPSocket-Send(char*) break;case WM_RBUTTONDBLCLK: memset(char*) command.ID=RbuttonDd; m_pRecBMPSocket-Send(char*) break;case WM_MOUSEWHEEL: memset(char*) command.ID=MouseWheel; command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) /AfxMessageBox(buf1); break; case WM_MBUTTONDOWN: memset(char*) command.ID=Mbd;command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) break;case WM_MBUTTONUP: memset(char*) command.ID=Mbu; command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) break;case WM_MBUTTONDBLCLK: memset(char*) command.ID=Mbdd; command.z=(short)HIWORD(pMsg-wParam); m_pRecBMPSocket-Send(char*) break; return CView:PreTranslateMessage(pMsg); 在客户端节接收命令:void CEmployerSocket:OnReceive(int nErrorCode) / TODO: Add your specialized code here and/or call the base classCSocket:OnReceive(nErrorCode);COMMAND command; BYTE *buf=(BYTE *)malloc(5120); int rec=Receive(buf,5120,0); /MsgTyperec-1=0; memcpy( / AfxMessageBox(MsgType); switch(command.ID) case B: m_pDlg-SendBITMAP(this); /接收类型为b /发送bitmap结构 break; case D: m_pDlg-SendBitData(this);/发送bitmap的数据 break; case Getmoses: GetMosesProc(command); break;case Lbuttond: LbuttondProc(command); break;case Lbuttonu: LbuttonuProc(command); break;case Rbuttond: RbuttondProc(command); break;case Rbuttonu: RbuttonuProc(command); break;case LbuttonDd: LbuttonDdProc(command); break;case RbuttonDd: RbuttonDdProc(command); break; case Mbd: MbdProc(command); break;case Mbu:MbuProc(command); break;case Mbdd: MbddProc(command); break;case MouseWheel: MouseWheelProc(command); break;case KeyDown: KeyDownProc(command); break;case KeyUp: KeyUpProc(command); break; default: break; DWORD GetMosesProc (COMMAND command) char buf1256; sprintf(buf1,“%d %d“,command.x, command.y); / AfxMessageBox(buf1); SetCursorPos(command.x, command.y); return 0; DWORD LbuttondProc(COMMAND command) mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); return 0; DWORD LbuttonuProc(COMMAND command) mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); return 0; DWORD RbuttondProc(COMMAND command) mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); return 0; DWORD RbuttonuProc(COMMAND command) mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); return 0; DWORD LbuttonDdProc(COMMAND command) mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); return 0; DWORD RbuttonDdProc(COMMAND command) mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); return 0; DWORD MbdProc(COMMAND command) mouse_event(MOUSEEVENTF_MIDDLEDOWN,0,0,0,0); return 0; DWORD MbuProc(COMMAND command) mouse_event(MOUSEEVENTF_MIDDLEUP,0,0,0,0); return 0; DWORD MbddProc(COMMAND command) /AfxMessageBox(“dd“);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号