/// <summary> Doubleclick callback function. </summary> /// <param name="nativeHost"> The Chromely native host interface. </param> public void DblClickCallbackFunc(IChromelyNativeHost nativeHost) { // Toggle between normal (restore) and maximized var state = nativeHost.GetWindowState(); if (state == WindowState.Maximize) { nativeHost.SetWindowState(WindowState.Normal); } else { nativeHost.SetWindowState(WindowState.Maximize); } }
private IntPtr WndProc(IntPtr hWnd, uint message, IntPtr wParam, IntPtr lParam) { var msg = (WM)message; var isDraggableArea = IsDraggableArea(msg, lParam); switch (msg) { case WM.LBUTTONDOWN: { if (!isDraggableArea) { break; } var state = _nativeHost.GetWindowState(); if (state == WindowState.Maximize) { break; } GetCursorPos(out var point); ScreenToClient(_nativeHost.Handle, ref point); _dragPoint = new POINT(point.X, point.Y); // TODO: For some reason it only works when called twice in a row. Try to resolve it later. SetCapture(hWnd); SetCapture(hWnd); return(IntPtr.Zero); } case WM.CAPTURECHANGED: { _hasCapture = lParam == hWnd; return(IntPtr.Zero); } case WM.MOUSEMOVE: { if (_hasCapture) { var currentPoint = new Point((int)lParam); var current = new Point(currentPoint.X, currentPoint.Y); ClientToScreen(_nativeHost.Handle, ref current); var position = new Point(current.X - _dragPoint.x, current.Y - _dragPoint.y); SetWindowPos(_nativeHost.Handle, IntPtr.Zero, position.X, position.Y, 0, 0, SWP.NOACTIVATE | SWP.NOZORDER | SWP.NOOWNERZORDER | SWP.NOSIZE); return(IntPtr.Zero); } break; } case WM.LBUTTONUP: { if (_hasCapture) { ReleaseCapture(); } break; } case WM.LBUTTONDBLCLK: { if (!isDraggableArea) { break; } _framelessOption.DblClick(_nativeHost); break; } } return(CallWindowProc(_originalWndProc, hWnd, message, wParam, lParam)); }