public IPlatformHandle GetCursor(StandardCursorType cursorType) { IPlatformHandle rv; if (!Cache.TryGetValue(cursorType, out rv)) { Cache[cursorType] = rv = new PlatformHandle( UnmanagedMethods.LoadCursor(IntPtr.Zero, new IntPtr(CursorTypeMapping[cursorType])), PlatformConstants.CursorHandleType); } return rv; }
public IPlatformHandle GetCursor(StandardCursorType cursorType) { IPlatformHandle rv; if (!Cache.TryGetValue(cursorType, out rv)) { Cache[cursorType] = rv = new PlatformHandle( GetCursor(CursorTypeMapping[cursorType]).Handle, "GTKCURSOR"); } return rv; }
private void CreateWindow() { // Ensure that the delegate doesn't get garbage collected by storing it as a field. _wndProcDelegate = new UnmanagedMethods.WndProc(WndProc); _className = Guid.NewGuid().ToString(); UnmanagedMethods.WNDCLASSEX wndClassEx = new UnmanagedMethods.WNDCLASSEX { cbSize = Marshal.SizeOf(typeof(UnmanagedMethods.WNDCLASSEX)), style = 0, lpfnWndProc = _wndProcDelegate, hInstance = Marshal.GetHINSTANCE(GetType().Module), hCursor = DefaultCursor, hbrBackground = IntPtr.Zero, lpszClassName = _className, }; ushort atom = UnmanagedMethods.RegisterClassEx(ref wndClassEx); if (atom == 0) { throw new Win32Exception(); } _hwnd = CreateWindowOverride(atom); if (_hwnd == IntPtr.Zero) { throw new Win32Exception(); } Handle = new PlatformHandle(_hwnd, PlatformConstants.WindowHandleType); if (UnmanagedMethods.ShCoreAvailable) { uint dpix, dpiy; var monitor = UnmanagedMethods.MonitorFromWindow( _hwnd, UnmanagedMethods.MONITOR.MONITOR_DEFAULTTONEAREST); if (UnmanagedMethods.GetDpiForMonitor( monitor, UnmanagedMethods.MONITOR_DPI_TYPE.MDT_EFFECTIVE_DPI, out dpix, out dpiy) == 0) { _scaling = dpix / 96.0; } } }