/// <summary> /// 消息处理 /// </summary> /// <param name="m">消息</param> /// <returns>是否处理</returns> public virtual int onMessage(ref Message m) { if (m_native != null) { if (m.Msg == WM_IME_SETCONTEXT && m.WParam.ToInt32() == 1) { ImmAssociateContext(m_hWnd, m_hImc); } if (m.Msg == m_pInvokeMsgID) { onInvoke(m.WParam.ToInt32()); } switch (m.Msg) { case WM_CHAR: { if (m_allowOperate) { KeyEventArgs e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | Control.ModifierKeys); char key = (char)e.KeyData; if (m_native.onChar(key)) { return(1); } } break; } case WM_KEYDOWN: case WM_SYSKEYDOWN: { if (m_allowOperate) { KeyEventArgs e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | Control.ModifierKeys); char key = (char)e.KeyData; bool handle = m_native.onPreviewKeyEvent(FCEventID.KEYDOWN, key); if (handle) { return(1); } else { m_native.onKeyDown(key); } } break; } case WM_KEYUP: case WM_SYSKEYUP: { if (m_allowOperate) { KeyEventArgs e = new KeyEventArgs(((Keys)((int)((long)m.WParam))) | Control.ModifierKeys); char key = (char)e.KeyData; m_native.onKeyUp(key); } break; } case WM_ERASEBKGND: return(1); case WM_IME_CHAR: { if (m_allowOperate) { if (m.WParam.ToInt32() == PM_REMOVE) { FCView control = m_native.FocusedControl; if (control != null) { StringBuilder str = new StringBuilder(); int size = ImmGetCompositionString(m_hImc, GCS_COMPSTR, null, 0); size += sizeof(Char); ImmGetCompositionString(m_hImc, GCS_RESULTSTR, str, size); } } } break; } case WM_LBUTTONDBLCLK: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 2; m_native.onMouseDown(newTouchInfo); m_native.onDoubleClick(newTouchInfo); } break; } case WM_LBUTTONDOWN: { if (m_allowOperate) { activeMirror(); FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseDown(newTouchInfo); } break; } case WM_LBUTTONUP: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseUp(newTouchInfo); } break; } case WM_MOUSEMOVE: { if (m_allowOperate) { if ((int)m.WParam == 1) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_firstTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseMove(newTouchInfo); } else if ((int)m.WParam == 2) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseMove(newTouchInfo); } else { FCTouchInfo newTouchInfo = new FCTouchInfo(); m_native.onMouseMove(newTouchInfo); } } break; } case WM_MOUSEWHEEL: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_delta = (int)m.WParam; m_native.onMouseWheel(newTouchInfo); } break; } case WM_PAINT: { FCSize displaySize = m_native.DisplaySize; FCRect paintRect = new FCRect(0, 0, displaySize.cx, displaySize.cy); onPaint(paintRect); break; } case WM_RBUTTONDBLCLK: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 2; m_native.onMouseDown(newTouchInfo); m_native.onDoubleClick(newTouchInfo); } break; } case WM_RBUTTONDOWN: { if (m_allowOperate) { activeMirror(); FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseDown(newTouchInfo); } break; } case WM_RBUTTONUP: { if (m_allowOperate) { FCTouchInfo newTouchInfo = new FCTouchInfo(); newTouchInfo.m_secondTouch = true; newTouchInfo.m_clicks = 1; m_native.onMouseUp(newTouchInfo); } break; } case WM_TIMER: { if (m.HWnd == m_hWnd) { int timerID = (int)m.WParam; m_native.onTimer(timerID); } break; } } } return(0); }