public virtual void ClientToScreen(ref Rectangle clientRect, out Rectangle screenRect) { screenRect = clientRect; User32Helpers.MapWindowPoints(this.Handle, IntPtr.Zero, ref screenRect); User32Methods.AdjustWindowRectEx(ref screenRect, this.GetStyles(), User32Methods.GetMenu(this.Handle) != IntPtr.Zero, this.GetExStyles()); }
private IntPtr WndProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam) { _prevWndProc = User32Helpers.GetWindowLongPtr(hWnd, WindowLongFlags.GWLP_USERDATA); var msg = (WM)uMsg; switch (msg) { case WM.LBUTTONDOWN: if (_forwardAction != null) { if (IsCursorInDraggableRegion(hWnd, lParam)) { Message message = new Message(); message.Hwnd = hWnd; message.Value = uMsg; message.WParam = wParam; message.LParam = lParam; _forwardAction(message); return(IntPtr.Zero); } } break; } return(User32Methods.CallWindowProc(_prevWndProc, hWnd, uMsg, wParam, lParam)); }
public static MessageBoxResult ShowError(object errorObject, string infoMessage = null, string title = null, IntPtr parentHwnd = default(IntPtr), MessageBoxFlags flags = MessageBoxFlags.MB_OK | MessageBoxFlags.MB_ICONERROR | MessageBoxFlags.MB_SYSTEMMODAL) { const string defaultTitle = "Error"; const string defaultInfoMessage = "Oh snap! Something went wrong."; title = title ?? defaultTitle; var ex = errorObject as Exception; if (ex == null) { return(User32Helpers.MessageBox(parentHwnd, infoMessage ?? defaultInfoMessage + $"\n\n{errorObject?.ToString() ?? "No additional information available."}", title, flags)); } var exMessage = ex.Message ?? "No information message available."; string msg; if (infoMessage != null) { msg = infoMessage + "\n\n" + exMessage; } else { msg = defaultInfoMessage + "\n\n" + exMessage; } return(User32Helpers.MessageBox(parentHwnd, $"{msg}" + $"\n\nStackTrace:\n\n{ex.StackTrace}", title, flags)); }
public virtual void ScreenToClient(ref Rectangle screenRect, out Rectangle clientRect) { clientRect = screenRect; User32Helpers.MapWindowPoints(IntPtr.Zero, this.Handle, ref clientRect); User32Helpers.InverseAdjustWindowRectEx(ref clientRect, this.GetStyles(), User32Methods.GetMenu(this.Handle) != IntPtr.Zero, this.GetExStyles()); }
private Cache() { this.ProcessHandle = Kernel32Methods.GetCurrentProcess(); this.AppIconHandle = User32Helpers.LoadIcon(IntPtr.Zero, SystemIcon.IDI_APPLICATION); this.ArrowCursorHandle = User32Helpers.LoadCursor(IntPtr.Zero, SystemCursor.IDC_ARROW); this.WindowClassExSize = (uint)Marshal.SizeOf <WindowClassEx>(); }
public static void SendMouseClick() { Input[] m_inputs = new Input[2]; Input.InitMouseInput(out m_inputs[0], 0, 0, MouseInputFlags.MOUSEEVENTF_LEFTDOWN, 0, 0); Input.InitMouseInput(out m_inputs[1], 0, 0, MouseInputFlags.MOUSEEVENTF_LEFTUP, 0, 50); var x = User32Helpers.SendInput(m_inputs); }
/// <summary> /// The create window. /// </summary> private void CreateWindow() { var instanceHandle = Kernel32Methods.GetModuleHandle(IntPtr.Zero); _windowProc = WindowProc; var wc = new WindowClassEx { Size = (uint)Marshal.SizeOf <WindowClassEx>(), ClassName = "chromelywindow", CursorHandle = User32Helpers.LoadCursor(IntPtr.Zero, SystemCursor.IDC_ARROW), IconHandle = GetIconHandle(), Styles = WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW, BackgroundBrushHandle = new IntPtr((int)StockObject.WHITE_BRUSH), WindowProc = _windowProc, InstanceHandle = instanceHandle }; var resReg = User32Methods.RegisterClassEx(ref wc); if (resReg == 0) { Log.Error("chromelywindow registration failed"); return; } var styles = GetWindowStyles(_hostConfig.HostPlacement.State); var placement = _hostConfig.HostPlacement; NativeMethods.RECT rect; rect.Left = placement.Left; rect.Top = placement.Top; rect.Right = placement.Left + placement.Width; rect.Bottom = placement.Top + placement.Height; NativeMethods.AdjustWindowRectEx(ref rect, styles.Item1, false, styles.Item2); var hwnd = User32Methods.CreateWindowEx( styles.Item2, wc.ClassName, _hostConfig.HostPlacement.Frameless ? string.Empty : _hostConfig.HostTitle, styles.Item1, rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top, IntPtr.Zero, IntPtr.Zero, instanceHandle, IntPtr.Zero); if (hwnd == IntPtr.Zero) { Log.Error("chromelywindow creation failed"); return; } User32Methods.ShowWindow(Handle, styles.Item3); User32Methods.UpdateWindow(Handle); }
public static uint Send(this IEnumerable <Input> inputs, TimeSpan AfterSleep) { var x = User32Helpers.SendInput(inputs.ToArray()); Thread.Sleep(AfterSleep); return(x); }
internal static void RemoveWindowFromTaskbar(IntPtr targetWindowHandle) { var newStyle = (WindowExStyles)User32Helpers.GetWindowLongPtr(targetWindowHandle, WindowLongFlags.GWL_EXSTYLE); newStyle &= ~WindowExStyles.WS_EX_APPWINDOW; User32Helpers.SetWindowLongPtr(targetWindowHandle, WindowLongFlags.GWL_EXSTYLE, new IntPtr((long)newStyle)); }
public static void SendSingleKey(Input[] m_inputs) { var x = User32Helpers.SendInput(m_inputs); Input.InitKeyboardInput(out m_inputs[0], VirtualKey.H, false); //Input.InitKeyboardInput(out m_inputs[0], , false); //Input.InitMouseInput(out m_inputs[0],0,0,0); }
internal static void MakeToolWindow(IntPtr targetWindowHandle) { var newStyle = (WindowStyles)User32Helpers.GetWindowLongPtr(targetWindowHandle, WindowLongFlags.GWL_STYLE); newStyle &= ~WindowStyles.WS_MAXIMIZEBOX; newStyle &= ~WindowStyles.WS_MINIMIZEBOX; User32Helpers.SetWindowLongPtr(targetWindowHandle, WindowLongFlags.GWL_STYLE, new IntPtr((long)newStyle)); }
public void Init(string title, int width, int height, bool vsync, bool fullscreen) { if (m_Info != null) { throw new InvalidOperationException("application already initialized"); } m_Info = new ApplicationInfo { Title = title, Width = width, Height = height, VSync = vsync, FullScreen = fullscreen }; IntPtr hInstance = Kernel32Methods.GetModuleHandle(IntPtr.Zero); m_WindowProc = WindowProc; var wc = new WindowClassEx { Size = (uint)Marshal.SizeOf <WindowClassEx>(), ClassName = "MainWindow", CursorHandle = User32Helpers.LoadCursor(IntPtr.Zero, SystemCursor.IDC_ARROW), IconHandle = User32Helpers.LoadIcon(IntPtr.Zero, SystemIcon.IDI_APPLICATION), Styles = WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW | WindowClassStyles.CS_OWNDC, BackgroundBrushHandle = new IntPtr((int)StockObject.WHITE_BRUSH), WindowProc = m_WindowProc, InstanceHandle = hInstance }; if (User32Methods.RegisterClassEx(ref wc) == 0) { throw new ExternalException("window registration failed"); } NetCoreEx.Geometry.Rectangle size = new NetCoreEx.Geometry.Rectangle(0, 0, width, height); User32Methods.AdjustWindowRectEx(ref size, WindowStyles.WS_OVERLAPPEDWINDOW | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS, false, WindowExStyles.WS_EX_APPWINDOW | WindowExStyles.WS_EX_WINDOWEDGE); m_hWnd = User32Methods.CreateWindowEx(WindowExStyles.WS_EX_APPWINDOW | WindowExStyles.WS_EX_WINDOWEDGE, wc.ClassName, title, WindowStyles.WS_OVERLAPPEDWINDOW | WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS, (int)CreateWindowFlags.CW_USEDEFAULT, (int)CreateWindowFlags.CW_USEDEFAULT, size.Right + (-size.Left), size.Bottom + (-size.Top), IntPtr.Zero, IntPtr.Zero, hInstance, IntPtr.Zero); if (m_hWnd == IntPtr.Zero) { throw new ExternalException("window creation failed"); } User32Methods.ShowWindow(m_hWnd, ShowWindowCommands.SW_SHOWNORMAL); User32Methods.UpdateWindow(m_hWnd); Context.Instance.Init(m_hWnd, m_Info); Renderer.Instance.Init(); Script.LuaEngine.Instance.Init(); }
public virtual void GetFrameThickness(out Rectangle rect) { this.m_window.GetClientRect(out rect); User32Helpers.MapWindowPoints(this.m_window.Handle, IntPtr.Zero, ref rect); // Don't add top, since the topMargin is calculated to be in parity // with client area already with the Dwm frame extension rect.Left += this.NcOutsetThickness.Left; rect.Right += this.NcOutsetThickness.Right; rect.Bottom += this.NcOutsetThickness.Bottom; }
private static bool IsMainWindow(IntPtr windowHandle) { var style = (WindowStyles)User32Helpers.GetWindowLongPtr(windowHandle, WindowLongFlags.GWL_STYLE); var isMinimized = (style & WindowStyles.WS_MINIMIZE) == WindowStyles.WS_MINIMIZE; return (User32Methods.IsWindow(windowHandle) && (User32Methods.IsWindowVisible(windowHandle) || isMinimized)); }
public static MessageBoxResult Show(string message, string title = null, IntPtr parentHwnd = default(IntPtr), MessageBoxFlags flags = MessageBoxFlags.MB_OK | MessageBoxFlags.MB_ICONINFORMATION) { const string defaultTitle = "Information"; title = title ?? defaultTitle; return(User32Helpers.MessageBox(parentHwnd, message, title, flags)); }
internal static void MakeLayeredWindow(IntPtr targetWindowHandle) { User32Helpers.SetWindowLongPtr( targetWindowHandle, WindowLongFlags.GWL_EXSTYLE, new IntPtr( (int)User32Helpers.GetWindowLongPtr(targetWindowHandle, WindowLongFlags.GWL_EXSTYLE) | (int)WindowExStyles.WS_EX_LAYERED ) ); }
/// <summary> /// The get icon handle. /// </summary> /// <returns> /// The <see cref="IntPtr"/>. /// </returns> private IntPtr GetIconHandle() { IntPtr?hIcon = NativeMethods.LoadIconFromFile(this.mHostConfig.HostIconFile); if (hIcon == null) { return(User32Helpers.LoadIcon(IntPtr.Zero, SystemIcon.IDI_APPLICATION)); } return(hIcon.Value); }
private static void SendKey(string key) { Input inputKey = new Input(); inputKey.Type = InputType.INPUT_KEYBOARD; inputKey.Packet.KeyboardInput.VirtualKeyCode = (ushort)VkKeyScan(char.Parse(key)); inputKey.Packet.KeyboardInput.Flags = KeyboardInputFlags.KEYEVENTF_UNICODE; inputKey.Packet.KeyboardInput.ScanCode = char.Parse(key); User32Helpers.SendInput(new[] { inputKey }); inputKey.Packet.KeyboardInput.Flags = KeyboardInputFlags.KEYEVENTF_UNICODE | KeyboardInputFlags.KEYEVENTF_KEYUP; User32Helpers.SendInput(new[] { inputKey }); }
static int Main(string[] args) { var instanceHandle = Kernel32Methods.GetModuleHandle(IntPtr.Zero); var wc = new WindowClassEx { Size = (uint)Marshal.SizeOf <WindowClassEx>(), ClassName = "MainWindow", CursorHandle = User32Helpers.LoadCursor(IntPtr.Zero, SystemCursor.IDC_ARROW), IconHandle = User32Helpers.LoadIcon(IntPtr.Zero, SystemIcon.IDI_APPLICATION), Styles = WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW, BackgroundBrushHandle = new IntPtr((int)StockObject.WHITE_BRUSH), WindowProc = WindowProc, InstanceHandle = instanceHandle }; var resReg = User32Methods.RegisterClassEx(ref wc); if (resReg == 0) { Console.Error.WriteLine("registration failed"); return(-1); } var hwnd = User32Methods.CreateWindowEx(WindowExStyles.WS_EX_APPWINDOW, wc.ClassName, "Hello", WindowStyles.WS_OVERLAPPEDWINDOW, (int)CreateWindowFlags.CW_USEDEFAULT, (int)CreateWindowFlags.CW_USEDEFAULT, (int)CreateWindowFlags.CW_USEDEFAULT, (int)CreateWindowFlags.CW_USEDEFAULT, IntPtr.Zero, IntPtr.Zero, instanceHandle, IntPtr.Zero); if (hwnd == IntPtr.Zero) { Console.Error.WriteLine("window creation failed"); return(-1); } User32Methods.ShowWindow(hwnd, ShowWindowCommands.SW_SHOWNORMAL); User32Methods.UpdateWindow(hwnd); Message msg; int res; while ((res = User32Methods.GetMessage(out msg, IntPtr.Zero, 0, 0)) != 0) { User32Methods.TranslateMessage(ref msg); User32Methods.DispatchMessage(ref msg); } return(res); }
public void CenterToScreen(bool useWorkArea = true) { var monitor = User32Methods.MonitorFromWindow(this.Handle, MonitorFlag.MONITOR_DEFAULTTONEAREST); MonitorInfo monitorInfo; User32Helpers.GetMonitorInfo(monitor, out monitorInfo); var screenRect = useWorkArea ? monitorInfo.WorkRect : monitorInfo.MonitorRect; var midX = screenRect.Width / 2; var midY = screenRect.Height / 2; var size = this.GetWindowSize(); this.SetPosition(midX - size.Width / 2, midY - size.Height / 2); }
/// <summary> /// The create window. /// </summary> private void CreateWindow() { var instanceHandle = Kernel32Methods.GetModuleHandle(IntPtr.Zero); var wc = new WindowClassEx { Size = (uint)Marshal.SizeOf <WindowClassEx>(), ClassName = "chromelywindow", CursorHandle = User32Helpers.LoadCursor(IntPtr.Zero, SystemCursor.IDC_ARROW), IconHandle = GetIconHandle(), Styles = WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW, BackgroundBrushHandle = new IntPtr((int)StockObject.WHITE_BRUSH), WindowProc = WindowProc, InstanceHandle = instanceHandle }; var resReg = User32Methods.RegisterClassEx(ref wc); if (resReg == 0) { Log.Error("chromelywindow registration failed"); return; } var styles = GetWindowStyles(mHostConfig.HostState); var hwnd = User32Methods.CreateWindowEx( styles.Item2, wc.ClassName, mHostConfig.HostTitle, styles.Item1, 0, 0, mHostConfig.HostWidth, mHostConfig.HostHeight, IntPtr.Zero, IntPtr.Zero, instanceHandle, IntPtr.Zero); if (hwnd == IntPtr.Zero) { Log.Error("chromelywindow creation failed"); return; } User32Methods.ShowWindow(Handle, styles.Item3); User32Methods.UpdateWindow(Handle); }
public override int RunCore() { Message msg; var quitMsgId = (uint)WM.QUIT; do { if (User32Helpers.PeekMessage(out msg, IntPtr.Zero, 0, 0, PeekMessageFlags.PM_REMOVE)) { User32Methods.TranslateMessage(ref msg); User32Methods.DispatchMessage(ref msg); } } while (msg.Value != quitMsgId); return(0); }
private static void SendShift(bool press) { Input inputShift = new Input(); uint shiftKey = MapVirtualKey((uint)Keys.ShiftKey, 0x0); inputShift.Type = InputType.INPUT_KEYBOARD; inputShift.Packet.KeyboardInput.Flags = KeyboardInputFlags.KEYEVENTF_SCANCODE; if (!press) { inputShift.Packet.KeyboardInput.Flags |= KeyboardInputFlags.KEYEVENTF_KEYUP; } inputShift.Packet.KeyboardInput.ScanCode = (ushort)shiftKey; User32Helpers.SendInput(new[] { inputShift }); }
private void ToggleFullScreen() { if (!isFullScreen) { isMaximized = User32Methods.IsZoomed(Handle); //if (isMaximized) // SetState(ShowWindowCommands.SW_RESTORE); windowStyles = GetStyles(); windowExStyles = GetExStyles(); GetWindowRect(out windowRect); SetStyle(windowStyles & ~(WindowStyles.WS_CAPTION | WindowStyles.WS_THICKFRAME)); SetExStyles(windowExStyles & ~(WindowExStyles.WS_EX_DLGMODALFRAME | WindowExStyles.WS_EX_WINDOWEDGE | WindowExStyles.WS_EX_CLIENTEDGE | WindowExStyles.WS_EX_STATICEDGE)); IntPtr monitor = User32Methods.MonitorFromWindow(Handle, MonitorFlag.MONITOR_DEFAULTTONEAREST); User32Helpers.GetMonitorInfo(monitor, out MonitorInfo monitorInfo); SetPosition(monitorInfo.MonitorRect, WindowPositionFlags.SWP_NOZORDER | WindowPositionFlags.SWP_NOACTIVATE | WindowPositionFlags.SWP_FRAMECHANGED); } else { SetStyle(windowStyles); SetExStyles(windowExStyles); SetPosition(windowRect, WindowPositionFlags.SWP_NOZORDER | WindowPositionFlags.SWP_NOACTIVATE | WindowPositionFlags.SWP_FRAMECHANGED); if (isMaximized) { SetState(ShowWindowCommands.SW_MAXIMIZE); } } isFullScreen = !isFullScreen; ResetTransformation(); }
protected override void OnCreate(ref CreateWindowPacket packet) { this.m_textBox = StaticBox.Create( "Ahoy!", hParent: this.Handle); this.m_editBox = EditBox.Create( "Nothing here yet.", hParent: this.Handle, controlStyles: EditBox.EditStyles.ES_MULTILINE | EditBox.EditStyles.ES_WANTRETURN | (EditBox.EditStyles)WindowStyles.WS_VSCROLL); this.m_layout.ClientArea = this.GetClientRect(); this.m_layout.Margin = new Rectangle(10, 10, 10, 10); this.m_layout.Children.Add(this.m_textBox); this.m_layout.Children.Add(this.m_editBox); this.m_layout.PerformLayout(); this.m_timerProc = (wnd, uMsg, eventId, millis) => { try { this.m_timesExecuted++; Input.InitKeyboardInput(out this.m_inputs[0], VirtualKey.H, false); Input.InitKeyboardInput(out this.m_inputs[1], VirtualKey.H, true); Input.InitKeyboardInput(out this.m_inputs[3], VirtualKey.E, false); Input.InitKeyboardInput(out this.m_inputs[4], VirtualKey.E, true); Input.InitKeyboardInput(out this.m_inputs[5], VirtualKey.L, false); Input.InitKeyboardInput(out this.m_inputs[6], VirtualKey.L, true); Input.InitKeyboardInput(out this.m_inputs[7], VirtualKey.L, false); Input.InitKeyboardInput(out this.m_inputs[8], VirtualKey.L, true); Input.InitKeyboardInput(out this.m_inputs[9], VirtualKey.O, false); Input.InitKeyboardInput(out this.m_inputs[10], VirtualKey.O, true); var x = User32Helpers.SendInput(this.m_inputs); } catch (Exception ex) { this.m_editBox.SetText($"ERROR: {ex.Message}\r\n{ex.StackTrace}"); } }; this.m_timerId = User32Methods.SetTimer(this.Handle, IntPtr.Zero, 20, this.m_timerProc); base.OnCreate(ref packet); }
/// <summary> /// The center to screen. /// </summary> /// <param name="useWorkArea"> /// The use work area. /// </param> public void CenterToScreen(bool useWorkArea = true) { var monitor = User32Methods.MonitorFromWindow(Handle, MonitorFlag.MONITOR_DEFAULTTONEAREST); User32Helpers.GetMonitorInfo(monitor, out var monitorInfo); var screenRect = useWorkArea ? monitorInfo.WorkRect : monitorInfo.MonitorRect; var midX = screenRect.Width / 2; var midY = screenRect.Height / 2; var size = GetWindowSize(); var left = midX - (size.Width / 2); var top = midY - (size.Height / 2); User32Methods.SetWindowPos( Handle, IntPtr.Zero, left, top, -1, -1, WindowPositionFlags.SWP_NOACTIVATE | WindowPositionFlags.SWP_NOSIZE | WindowPositionFlags.SWP_NOZORDER); }
/// <summary> /// The run core. /// </summary> /// <returns> /// The <see cref="int"/>. /// </returns> public override int RunCore() { var quitMsg = (uint)WM.QUIT; bool isMultiThreadedLoopSet = this.mHostConfig.GetBooleanValue(CefSettingKeys.MultiThreadedMessageLoop, true); bool isExternalPumpSet = this.mHostConfig.GetBooleanValue(CefSettingKeys.ExternalMessagePump); if (!isMultiThreadedLoopSet && !isExternalPumpSet) { CefRuntime.RunMessageLoop(); } else { while (true) { Message msg; if (User32Helpers.PeekMessage(out msg, IntPtr.Zero, 0, 0, PeekMessageFlags.PM_REMOVE)) { if (msg.Value == quitMsg) { break; } User32Methods.TranslateMessage(ref msg); User32Methods.DispatchMessage(ref msg); } // Do your idle processing if (isExternalPumpSet) { CefRuntime.DoMessageLoopWork(); } } } return(0); }
/// <summary> /// The get icon handle. /// </summary> /// <returns> /// The <see cref="IntPtr"/>. /// </returns> private IntPtr GetIconHandle() { var hIcon = NativeMethods.LoadIconFromFile(mHostConfig.HostIconFile); return(hIcon ?? User32Helpers.LoadIcon(IntPtr.Zero, SystemIcon.IDI_APPLICATION)); }
internal static void SetWindowOwner(IntPtr targetWindoHandle, IntPtr parentWindowHandle) { User32Helpers.SetWindowLongPtr(targetWindoHandle, WindowLongFlags.GWLP_HWNDPARENT, parentWindowHandle); }
/// <summary> /// The create window. /// </summary> private void CreateWindow() { var instanceHandle = Kernel32Methods.GetModuleHandle(IntPtr.Zero); _windowProc = WindowProc; var wc = new WindowClassEx { Size = (uint)Marshal.SizeOf <WindowClassEx>(), ClassName = "chromelywindow", CursorHandle = User32Helpers.LoadCursor(IntPtr.Zero, SystemCursor.IDC_ARROW), IconHandle = GetIconHandle(), Styles = WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW, BackgroundBrushHandle = new IntPtr((int)StockObject.WHITE_BRUSH), WindowProc = _windowProc, InstanceHandle = instanceHandle }; var resReg = User32Methods.RegisterClassEx(ref wc); if (resReg == 0) { Log.Error("chromelywindow registration failed"); return; } var styles = GetWindowStyles(_hostConfig.HostPlacement.State); var placement = _hostConfig.HostPlacement; NativeMethods.RECT rect; rect.Left = placement.Left; rect.Top = placement.Top; rect.Right = placement.Left + placement.Width; rect.Bottom = placement.Top + placement.Height; NativeMethods.AdjustWindowRectEx(ref rect, styles.Item1, false, styles.Item2); var hwnd = User32Methods.CreateWindowEx( styles.Item2, wc.ClassName, _hostConfig.HostPlacement.Frameless ? string.Empty : _hostConfig.HostTitle, styles.Item1, rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top, IntPtr.Zero, IntPtr.Zero, instanceHandle, IntPtr.Zero); if (hwnd == IntPtr.Zero) { Log.Error("chromelywindow creation failed"); return; } if (_hostConfig.HostPlacement.KioskMode) { //// Set new window style and size. var windowHDC = User32Methods.GetDC(Handle); var fullscreenWidth = Gdi32Methods.GetDeviceCaps(windowHDC, (int)DeviceCapsParams.HORZRES); var fullscreenHeight = Gdi32Methods.GetDeviceCaps(windowHDC, (int)DeviceCapsParams.VERTRES); User32Methods.ReleaseDC(Handle, windowHDC); User32Methods.SetWindowLongPtr(Handle, (int)WindowLongFlags.GWL_STYLE, (IntPtr)styles.Item1); User32Methods.SetWindowLongPtr(Handle, (int)WindowLongFlags.GWL_EXSTYLE, (IntPtr)styles.Item2); User32Methods.SetWindowPos(Handle, (IntPtr)HwndZOrder.HWND_TOP, 0, 0, fullscreenWidth, fullscreenHeight, WindowPositionFlags.SWP_NOZORDER | WindowPositionFlags.SWP_FRAMECHANGED); User32Methods.ShowWindow(Handle, ShowWindowCommands.SW_MAXIMIZE); try { this._hookID = NativeMethods.SetHook(_hookCallback); } catch { DetachKeyboardHook(); } } else { User32Methods.ShowWindow(Handle, styles.Item3); } User32Methods.UpdateWindow(Handle); User32Methods.RegisterHotKey(IntPtr.Zero, 1, KeyModifierFlags.MOD_CONTROL, VirtualKey.L); }