internal MouseHookEventArgs(System.IntPtr wparam, System.IntPtr lparam) { if (!System.Enum.IsDefined(typeof(MouseMessages), (int) wparam.ToInt32())) { this.message = MouseMessages.Unknown; } else { this.message = (MouseMessages) wparam.ToInt32(); } MOUSEHOOKSTRUCT mousehookstruct = (MOUSEHOOKSTRUCT) System.Runtime.InteropServices.Marshal.PtrToStructure(lparam, typeof(MOUSEHOOKSTRUCT)); this.point = new System.Drawing.Point(mousehookstruct.pt.x, mousehookstruct.pt.y); this.hwnd = mousehookstruct.hwnd; this.hitTestCode = (HitTestCodes) mousehookstruct.hitTestCode; this.extraInfo = mousehookstruct.extraInfo; }
private int HookCallbackProc(int nCode, System.IntPtr wParam, System.IntPtr lParam) { if (nCode < 0) { return ColorPicker_NativeMethods.CallNextHookEx(m_hHook, nCode, wParam, lParam); } else { //Marshall the data from the callback. WinUtil.KeyboardHookStruct hookstruct = (WinUtil.KeyboardHookStruct) System.Runtime.InteropServices.Marshal.PtrToStructure(lParam, typeof (WinUtil.KeyboardHookStruct)); if (OnKeyDown != null && wParam.ToInt32() == WinUtil.WM_KEYDOWN) { System.Windows.Forms.Keys key = (System.Windows.Forms.Keys) hookstruct.vkCode; if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) == System.Windows.Forms.Keys.Shift) key |= System.Windows.Forms.Keys.Shift; if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Control) == System.Windows.Forms.Keys.Control) key |= System.Windows.Forms.Keys.Control; var e = new System.Windows.Forms.KeyEventArgs(key); e.Handled = false; OnKeyDown(e); if (e.Handled) return 1; } int result = 0; if (m_hHook != 0) result = ColorPicker_NativeMethods.CallNextHookEx(m_hHook, nCode, wParam, lParam); return result; } }
private int HookCallbackProc(int nCode, System.IntPtr wParam, System.IntPtr lParam) { if (nCode < 0) { return NativeMethods.CallNextHookEx(this.m_hHook, nCode, wParam, lParam); } else { //Marshall the data from the callback. var hookstruct = (WinUtil.KeyboardHookStruct) System.Runtime.InteropServices.Marshal.PtrToStructure(lParam, typeof(WinUtil.KeyboardHookStruct)); if (this.OnKeyDown != null && wParam.ToInt32() == WinUtil.WM_KEYDOWN) { var key = (Keys) hookstruct.vkCode; const Keys shift = Keys.Shift; const Keys control = Keys.Control; Keys modkeys = Control.ModifierKeys; if ((modkeys & shift) == shift) { key |= shift; } if ((modkeys & control) == control) { key |= control; } var e = new KeyEventArgs(key); e.Handled = false; this.OnKeyDown(e); if (e.Handled) { return 1; } } int result = 0; if (this.m_hHook != 0) { result = NativeMethods.CallNextHookEx(this.m_hHook, nCode, wParam, lParam); } return result; } }
// display windows dialog private void displayDialog(System.IntPtr wndHandle, int dialogToShow) { // prep variables int i = -1; int iHandle = 0; // get parent handle if (wndHandle != System.IntPtr.Zero) iHandle = wndHandle.ToInt32(); // choose dialog to show bassed on if (dialogToShow == 1) i = WNetConnectionDialog(iHandle, RESOURCETYPE_DISK); else if (dialogToShow == 2) i = WNetDisconnectDialog(iHandle, RESOURCETYPE_DISK); // if error returned, throw if (i > 0) throw new System.ComponentModel.Win32Exception(i); }
private static void ManageButtons(System.IntPtr device, System.IntPtr cookie, System.IntPtr value) { if (cookie.ToInt32() < 0 || cookie.ToInt32() > 19) return; Engine.Joystick joystick = GetJoystick (device); if (joystick == null) return; int buttonPressed = MacNative.IOHIDValueGetIntegerValue (value).ToInt32 (); joystick.buttons [cookie.ToInt32()] = buttonPressed >= 1; }