Пример #1
0
 // 处理消息
 protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
 {
     switch (msg)
     {
     case WM_COPYDATA:
         COPYDATASTRUCT cds = (COPYDATASTRUCT)Marshal.PtrToStructure(lParam, typeof(COPYDATASTRUCT));
         string         str = cds.lpData;
         Txb_Receiver.AppendText(str + "\n");
         handled = true;
         break;
     }
     return(hwnd);
 }
Пример #2
0
        // 重载消息处理
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case USER_TEXT_MSG:
                // 用户文本消息
                COPYDATASTRUCT mystr  = new COPYDATASTRUCT();
                Type           mytype = mystr.GetType();
                mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
                string str = mystr.lpData;
                Txb_Receiver.AppendText(str + "\n");

                break;

            default:
                // 系统处理其它消息
                base.DefWndProc(ref m);
                break;
            }
        }