/// <summary> /// Allow a select set of keys be active when using the IDocHostUIHandler interface /// </summary> /// <param name="lpmsg">the message/key combination</param> public void AllowKeysForIDocHostUIHandler(tagMSG lpmsg) { CheckDisposed(); const int WM_KEYDOWN = 0x0100; const int VK_CONTROL = 0x11; if (lpmsg.message == WM_KEYDOWN) { switch (lpmsg.wParam) { case (uint)Keys.Down: // all of these are the same: allow them to have their normal function case (uint)Keys.Up: case (uint)Keys.Left: case (uint)Keys.Right: case (uint)Keys.PageDown: case (uint)Keys.PageUp: throw new COMException("", 1); // returns HRESULT = S_FALSE case (uint)Keys.F: // all of these are the same: allow these control key sequences case (uint)Keys.End: case (uint)Keys.Home: if (GetAsyncKeyState(VK_CONTROL) < 0) { throw new COMException("", 1); // returns HRESULT = S_FALSE } break; default: break; // do nothing } } }
public uint TranslateAccelerator(ref tagMSG lpMsg, ref Guid pguidCmdGroup, uint nCmdID) { if (this.m_defaultUIHandler != null) { return(this.m_defaultUIHandler.TranslateAccelerator(ref lpMsg, ref pguidCmdGroup, nCmdID)); } return(0); }
/// <summary> /// 接收系统消息 /// </summary> /// <param name="msg">系统消息</param> protected override void WndProc(ref Message msg) { if (beginInit && EngineLayer.ATLBase != null) { int ret = 0; tagMSG tmsg = new tagMSG(); tmsg.hwnd = (IntPtr)msg.HWnd; tmsg.lParam = (int)(msg.LParam); tmsg.message = Convert.ToUInt32(msg.Msg); tmsg.wParam = (uint)(msg.WParam); EngineLayer.ATLBase.OnWndMsg(ref tmsg, ref ret, previewType); } base.WndProc(ref msg); }
uint IDocHostUIHandler.TranslateAccelerator(ref tagMSG lpmsg, uint pguidCmdGroup, uint nCmdID) { try { if (_window.translate_accelerator_handler_ != null && _window.translate_accelerator_handler_ != DBNull.Value ) { object ret = Convert.ToBoolean(Utility.CallFunc(_window.translate_accelerator_handler_, _window.IWindow, lpmsg.message, lpmsg.lParam, lpmsg.wParam)); if (Convert.ToBoolean(ret)) { return(S_OK); } } } catch { } return(E_NOTIMPL); }
int IDocHostUIHandler.TranslateAccelerator(ref tagMSG msg, ref Guid group, uint nCmdID) { // return Hresults.S_OK; //Cancel // return Hresults.S_FALSE; //IE default action Keys nVirtExtKey = Keys.None; // (int)0; if ((ModifierKeys & Keys.Control) != 0) { nVirtExtKey = Keys.ControlKey; //CONTROL 17 } if ((ModifierKeys & Keys.ShiftKey) != 0) { nVirtExtKey = Keys.ShiftKey; //SHIFT 16 } if ((ModifierKeys & Keys.Menu) != 0) { nVirtExtKey = Keys.Menu; //ALT 18 } Keys keyCode = (Keys)msg.wParam; if ((msg.message == WindowsMessages.WM_KEYDOWN) && (WBKeyDown != null)) { WBKeyDownEvent.SetParameters(keyCode, nVirtExtKey); WBKeyDown(this, WBKeyDownEvent); if (WBKeyDownEvent.handled) { return(Hresults.S_OK); } } if ((msg.message == WindowsMessages.WM_KEYUP) && (WBKeyUp != null)) { WBKeyUpEvent.SetParameters(keyCode, nVirtExtKey); WBKeyUp(this, WBKeyUpEvent); if (WBKeyUpEvent.handled == true) { return(Hresults.S_OK); } } //IE default action return(Hresults.S_FALSE); }
protected override void WndProc(ref Message msg) { try { if (BaseForm.K3DEngine != null) { string name = bf_parent.ModelName + "[" + bf_parent.tabControl.SelectedTabIndex.ToString() + "]"; tagMSG tmsg = new tagMSG(); tmsg.hWnd = (IntPtr)msg.HWnd; tmsg.lParam = (int)(msg.LParam); tmsg.message = Convert.ToUInt32(msg.Msg); tmsg.wParam = (uint)(msg.WParam); BaseForm.K3DEngine.OnWndMsg(name, ref tmsg); } base.WndProc(ref msg); } catch (Exception) { } }
uint IDocHostUIHandler.TranslateAccelerator(ref tagMSG lpmsg, uint pguidCmdGroup, uint nCmdID) { try { if (_window.translate_accelerator_handler_ != null && _window.translate_accelerator_handler_ != DBNull.Value ) { object ret = Convert.ToBoolean(Utility.CallFunc(_window.translate_accelerator_handler_, _window.IWindow, lpmsg.message, lpmsg.lParam, lpmsg.wParam)); if (Convert.ToBoolean(ret)) return S_OK; } } catch { } return E_NOTIMPL; }
void IDocHostUIHandler.TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID) { const int Ok = 0; const int Error = 1; const int VK_BACK = 0x08; const int WM_KEYDOWN = 0x0100; const int WM_KEYUP = 0x0101; const int VK_CONTROL = 0x11; const int VK_ALT = 0x12; if (lpmsg.message != WM_KEYUP) { if (GetAsyncKeyState(VK_BACK) < 0) { mshtml.IHTMLDocument2 htmlDoc = axWebBrowser1.Document as mshtml.IHTMLDocument2; mshtml.IHTMLElement htmlElement = htmlDoc.activeElement as mshtml.IHTMLElement; string activeTag = htmlElement.tagName.ToLower(); if (activeTag == "a") { throw new COMException("", Ok); // returns HRESULT = S_OK } } } if (lpmsg.message != WM_KEYDOWN) { // allow message throw new COMException("", Error); // returns HRESULT = S_FALSE } if (GetAsyncKeyState(VK_CONTROL) < 0) //CONTROL KEY PRESSED { // disable all control keys except Ctrl-A Ctrl-C and Ctrl-V lpmsg.lParam &= 0xFF; // get the virtual keycode if ((lpmsg.lParam != 'A') || ((lpmsg.lParam != 'C')) || ((lpmsg.lParam != 'V'))) { throw new COMException("", Ok); // returns HRESULT = S_OK } } else if (GetAsyncKeyState(VK_ALT) < 0) //ALT KEY PRESSED { //disable all Alt key actions throw new COMException("", Ok); // returns HRESULT = S_OK } else { // Ctrl key not pressed: allow message mshtml.IHTMLDocument2 htmlDoc = axWebBrowser1.Document as mshtml.IHTMLDocument2; mshtml.IHTMLElement htmlElement = htmlDoc.activeElement as mshtml.IHTMLElement; string activeTag = htmlElement.tagName.ToLower(); string activeElementType = htmlElement.getAttribute("type", 0).ToString(); if (GetAsyncKeyState(VK_BACK) < 0) { if ((activeTag == "input" && activeElementType == "text") || activeTag == "textarea" || activeTag == "text" || activeTag == "password") { throw new COMException("", Error); // returns HRESULT = S_FALSE } else { throw new COMException("", Ok); // returns HRESULT = S_OK } } } // allow everything else throw new COMException("", Error); // returns HRESULT = S_FALSE }
public static extern int OleTranslateAccelerator(ref IOleInPlaceFrame lpFrame, ref tagOIFI lpFrameInfo, ref tagMSG lpmsg);
void IDocHostUIHandler.TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID) { }
public static extern bool TranslateMessage([In] ref tagMSG lpMsg);
void IDocHostUIHandler.TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID) { throw new COMException("", 1); // return 1 }
public static extern int DispatchMessage(ref tagMSG lpMsg); //函数将键盘消息转化
public static extern int GetMessage( //调用线程的消息队列里取得一个消息并将其放于指定的结构.此函数可取得与指定窗口联系的消息和由PostThreadMessage寄送的线程消息 out tagMSG lpMsg, //指向MSG结构的指针,该结构从线程的消息队列里接收消息信息。 IntPtr hwnd, //取得其消息的窗口的句柄。当其值取NULL时,GetMessage为任何属于调用线程的窗口检索消息,线程消息通过PostThreadMessage寄送给调用线程。 int wMsgFilterMin, //指定被检索的最小消息值的整数。 int wMsgFilterMax //指定被检索的最大消息值的整数。 );
public static extern int TranslateMessage(ref tagMSG lpMsg);
public static extern int GetMessage(out tagMSG lpMsg, IntPtr hwnd, int wMsgFilterMin, int wMsgFilterMax);
public static extern int TranslateAcceleratorA([In] IntPtr hWnd, [In] IntPtr hAccTable, [In] ref tagMSG lpMsg);
public static extern bool TranslateMDISysAccel([In] IntPtr hWndClient, [In] ref tagMSG lpMsg);
public void TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID) { throw new COMException("", 1); // returns HRESULT = S_FALSE }
public void TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID) { throw new NotImplementedException(); }
public static extern bool PeekMessageA([Out] out tagMSG lpMsg, [In] IntPtr hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
public static extern int TranslateMessage(ref tagMSG lpMsg); //函数将消息传给窗体函数去处理
/// <summary> /// Allow a select set of keys be active when using the IDocHostUIHandler interface /// </summary> /// <param name="lpmsg">the message/key combination</param> public void AllowKeysForIDocHostUIHandler(tagMSG lpmsg) { CheckDisposed(); const int WM_KEYDOWN = 0x0100; const int VK_CONTROL = 0x11; if (lpmsg.message == WM_KEYDOWN) { switch (lpmsg.wParam) { case (uint)Keys.Down: // all of these are the same: allow them to have their normal function case (uint)Keys.Up: case (uint)Keys.Left: case (uint)Keys.Right: case (uint)Keys.PageDown: case (uint)Keys.PageUp: throw new COMException("", 1); // returns HRESULT = S_FALSE case (uint) Keys.F: // all of these are the same: allow these control key sequences case (uint) Keys.End: case (uint) Keys.Home: if (GetAsyncKeyState(VK_CONTROL) < 0) throw new COMException("", 1); // returns HRESULT = S_FALSE break; default: break; // do nothing } } }
public void TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID) { }
public void TranslateAccelerator(ref tagMSG lpmsg, ref Guid pguidCmdGroup, uint nCmdID) { //throw new COMException("Not handled",1); }