/// <summary> /// Find element at point x/y of the window, client area relative /// </summary> public SciterElement ElementAtPoint(int x, int y) { PInvokeUtils.POINT pt = new PInvokeUtils.POINT() { X = x, Y = y }; IntPtr outhe; _api.SciterFindElement(_hwnd, pt, out outhe); if (outhe == IntPtr.Zero) { return(null); } return(new SciterElement(outhe)); }
/// <summary> /// Find element at point x/y of the window, client area relative /// </summary> public SciterElement ElementAtPoint(int x, int y) { PInvokeUtils.POINT pt = new PInvokeUtils.POINT() { X = x, Y = y }; IntPtr outhe; var r = _api.SciterFindElement(_hwnd, pt, out outhe); Debug.Assert(r == SciterXDom.SCDOM_RESULT.SCDOM_OK); if (outhe == IntPtr.Zero) { return(null); } return(new SciterElement(outhe)); }
public static void ShowPopup() { NSWindow wnd = (NSWindow)_sItem.ValueForKey(new NSString("window")); //var f1 = NSApplication.SharedApplication.CurrentEvent.Window.Frame; //var f2 = wnd.Frame; var frm = wnd.Frame; var pos = new PInvokeUtils.POINT() { X = ((int)frm.Left - App.AppWnd.Size.cx / 2) + ((int)frm.Width / 2), Y = (int)frm.Top - 1 }; NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); App.AppWnd._nsview.Window.OrderFrontRegardless(); App.AppWnd.CallFunction("View_ShowAnimate", new SciterValue(pos.X), new SciterValue(pos.Y)); }
public static void ShowPopup() { NSWindow wnd = (NSWindow)_sItem.ValueForKey(new NSString("window")); //var f1 = NSApplication.SharedApplication.CurrentEvent.Window.Frame; //var f2 = wnd.Frame; var screen = wnd.Screen; if (screen == null) { screen = NSScreen.MainScreen; } var scrfrm = screen.VisibleFrame; int w = 670; int h = (int)scrfrm.Height - 50; int offx_arrow = 0; var pos = new PInvokeUtils.POINT() { X = ((int)wnd.Frame.Left - w / 2) + ((int)wnd.Frame.Width / 2), Y = (int)wnd.Frame.Top - 1 }; if (pos.X + w > scrfrm.Width) { offx_arrow = (int)(pos.X + w - scrfrm.Width); pos.X = (int)(scrfrm.Width - w); } NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); App.AppWnd._nsview.Window.OrderFrontRegardless(); App.AppWnd.CallFunction("View_ShowOSX", new SciterValue(pos.X), new SciterValue(pos.Y), new SciterValue(w), new SciterValue(h), new SciterValue(offx_arrow)); //CoreFoundation.DispatchQueue.MainQueue.DispatchAsync(() => { //}); }
static extern bool ScreenToClient(IntPtr hWnd, ref PInvokeUtils.POINT lpPoint);
protected override bool ProcessWindowMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam, ref IntPtr lResult) { if (msg == WM_NCCALCSIZE) { bool bCalcValidRects = wParam.ToInt32() != 0; if (bCalcValidRects) { lResult = IntPtr.Zero; return(true); } } else if (msg == WM_NCHITTEST) { if (DwmDefWindowProc(hwnd, msg, wParam, lParam, out lResult) != 0) { return(true); } PInvokeUtils.POINT p = new PInvokeUtils.POINT() { X = LoWord((int)lParam), Y = HiWord((int)lParam) }; const int LEFT_WIDTH = 8; const int RIGHT_WIDTH = 8; const int BOTTOM_WIDTH = 8; const int TOP_WIDTH = 8; PInvokeUtils.RECT rcWindow; GetWindowRect(_hwnd, out rcWindow); int uRow = 1; int uCol = 1; if (p.Y >= rcWindow.top && p.Y < rcWindow.top + TOP_WIDTH) { uRow = 0; } else if (p.Y < rcWindow.bottom && p.Y >= rcWindow.bottom - BOTTOM_WIDTH) { uRow = 2; } if (p.X >= rcWindow.left && p.X < rcWindow.left + LEFT_WIDTH) { uCol = 0; } else if (p.X < rcWindow.right && p.X >= rcWindow.right - RIGHT_WIDTH) { uCol = 2; } int[,] hitTests = new int[3, 3] { { HTTOPLEFT, HTTOP, HTTOPRIGHT }, { HTLEFT, HTCLIENT, HTRIGHT }, { HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT }, }; lResult = new IntPtr(hitTests[uRow, uCol]); if (hitTests[uRow, uCol] == HTCLIENT) { ScreenToClient(_hwnd, ref p); var el = ElementAtPoint(p.X, p.Y); Debug.WriteLine(el.ToString()); if (el != null && el.Test("caption#area-glass")) { lResult = new IntPtr(HTCAPTION); } } return(true); } else if (msg == WM_SIZE) { if (wParam.ToInt32() == (int)WmSizeType.SIZE_MAXIMIZED) { _is_maximized = true; SetWindowPos(_hwnd, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_FRAMECHANGED); RootElement.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_EXPANDED, 0); } else if (wParam.ToInt32() == (int)WmSizeType.SIZE_RESTORED && _is_maximized) { _is_maximized = false; SetWindowPos(_hwnd, IntPtr.Zero, 0, 0, 0, 0, SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_FRAMECHANGED); RootElement.SetState(0, SciterXDom.ELEMENT_STATE_BITS.STATE_EXPANDED); } } return(false); }
public static SciterPoint ToPoint(this PInvokeUtils.POINT point) => new SciterPoint(point.X, point.Y);
protected override bool ProcessWindowMessage(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam, ref IntPtr lResult) { if (msg == WM_NCHITTEST) { if (DwmDefWindowProc(hwnd, msg, wParam, lParam, out lResult) != 0) { return(true); } PInvokeUtils.POINT p = new PInvokeUtils.POINT() { X = LoWord((int)lParam), Y = HiWord((int)lParam) }; const int LEFT_WIDTH = 8; const int RIGHT_WIDTH = 8; const int BOTTOM_WIDTH = 8; const int TOP_WIDTH = 8; PInvokeUtils.RECT rcWindow; GetWindowRect(_hwnd, out rcWindow); int uRow = 1; int uCol = 1; if (p.Y >= rcWindow.top && p.Y < rcWindow.top + TOP_WIDTH) { uRow = 0; } else if (p.Y < rcWindow.bottom && p.Y >= rcWindow.bottom - BOTTOM_WIDTH) { uRow = 2; } if (p.X >= rcWindow.left && p.X < rcWindow.left + LEFT_WIDTH) { uCol = 0; } else if (p.X < rcWindow.right && p.X >= rcWindow.right - RIGHT_WIDTH) { uCol = 2; } int[,] hitTests = new int[3, 3] { { HTTOPLEFT, HTTOP, HTTOPRIGHT }, { HTLEFT, HTCLIENT, HTRIGHT }, { HTBOTTOMLEFT, HTBOTTOM, HTBOTTOMRIGHT }, }; lResult = new IntPtr(hitTests[uRow, uCol]); if (hitTests[uRow, uCol] == HTCLIENT) { ScreenToClient(_hwnd, ref p); var el = ElementAtPoint(p.X, p.Y); if (el != null && el.Test("caption#area-glass")) { Debug.WriteLine(el.ToString()); lResult = new IntPtr(HTCAPTION); } } return(true); } if (_dwm_extended) { if (msg == WM_NCCALCSIZE) { bool bCalcValidRects = wParam.ToInt32() != 0; if (bCalcValidRects) { lResult = IntPtr.Zero; return(true); } } } return(false); }