private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) { WinFormsKeys virtualKey; switch (msg) { case Win32Native.WM_KEYDOWN: case Win32Native.WM_SYSKEYDOWN: virtualKey = (WinFormsKeys)wParam.ToInt64(); virtualKey = GetCorrectExtendedKey(virtualKey, lParam.ToInt64()); OnKeyEvent(virtualKey, false); break; case Win32Native.WM_KEYUP: case Win32Native.WM_SYSKEYUP: virtualKey = (WinFormsKeys)wParam.ToInt64(); virtualKey = GetCorrectExtendedKey(virtualKey, lParam.ToInt64()); OnKeyEvent(virtualKey, true); break; } var result = Win32Native.CallWindowProc(defaultWndProc, hWnd, msg, wParam, lParam); return(result); }
private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) { if (this.isDisposed) { this.RestoreWndProc(); } else { var message = new Message() { HWnd = hwnd, LParam = lParam, Msg = msg, WParam = wParam }; foreach (var messageFilter in this.currentFilters) { if (messageFilter.PreFilterMessage(ref message)) { return(message.Result); } } } var result = Win32Native.CallWindowProc(defaultWndProc, hWnd, msg, wParam, lParam); return(result); }
private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) { switch (msg) { case 0x118: // Cursor blink message return(new IntPtr(0)); case Win32Native.WM_KEYDOWN: case Win32Native.WM_SYSKEYDOWN: winformSource.HandleKeyDown(wParam, lParam); if (richTextBox.TextLength == 0) { var virtualKey = (System.Windows.Forms.Keys)wParam.ToInt64(); if (virtualKey == System.Windows.Forms.Keys.Back || virtualKey == System.Windows.Forms.Keys.Left || virtualKey == System.Windows.Forms.Keys.Right || virtualKey == System.Windows.Forms.Keys.Delete || virtualKey == System.Windows.Forms.Keys.Home || virtualKey == System.Windows.Forms.Keys.End || virtualKey == System.Windows.Forms.Keys.Up || virtualKey == System.Windows.Forms.Keys.Down) { // Swallow some keys when the text box is empty to prevent ding sound return(new IntPtr(0)); } } break; case Win32Native.WM_KEYUP: case Win32Native.WM_SYSKEYUP: winformSource.HandleKeyUp(wParam, lParam); break; case Win32Native.WM_IME_COMPOSITION: OnComposition(hWnd, (int)lParam); break; case Win32Native.WM_NCPAINT: case Win32Native.WM_PAINT: var paintStruct = new Win32Native.PAINTSTRUCT(); Win32Native.BeginPaint(hWnd, ref paintStruct); Win32Native.EndPaint(hWnd, ref paintStruct); // Don't paint the control return(new IntPtr(0)); } return(Win32Native.CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam)); }
/// <summary> /// Fixes issues specific to the Windows platform. /// </summary> /// <param name="sysinfo">The current system information.</param> private void FixPlatformSpecificIssues_Windows(ref SDL_SysWMinfo sysinfo) { // NOTE: This fix prevents Windows from playing the "ding" sound when // a key binding involving the Alt modifier is pressed. wndProc = new Win32Native.WndProcDelegate((hWnd, msg, wParam, lParam) => { const Int32 WM_SYSCOMMAND = 0x0112; const Int32 SC_KEYMENU = 0xF100; if (msg == WM_SYSCOMMAND && (wParam.ToInt64() & 0xfff0) == SC_KEYMENU) { return(IntPtr.Zero); } return(Win32Native.CallWindowProc(wndProcPrev, hWnd, msg, wParam, lParam)); }); const int GWLP_WNDPROC = -4; wndProcPrev = Win32Native.SetWindowLongPtr(sysinfo.info.win.window, GWLP_WNDPROC, Marshal.GetFunctionPointerForDelegate(wndProc)); }
private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam) { switch (msg) { case Win32Native.WM_KEYDOWN: case Win32Native.WM_SYSKEYDOWN: HandleKeyDown(wParam, lParam); break; case Win32Native.WM_KEYUP: case Win32Native.WM_SYSKEYUP: HandleKeyUp(wParam, lParam); break; case Win32Native.WM_DEVICECHANGE: // Trigger scan on device changed input.Scan(); break; } var result = Win32Native.CallWindowProc(defaultWndProc, hWnd, msg, wParam, lParam); return(result); }